Skip to main content
Glama

evm_unstake_lp

Withdraw staked LP tokens from yield farms and optionally claim pending rewards to exit a farming position or rebalance liquidity.

Instructions

Unstake LP tokens from yield farms, optionally claiming pending rewards.

Withdraws staked LP tokens from farming contracts back to wallet. Can simultaneously claim accumulated farming rewards or leave them unclaimed for later.

CRITICAL RULES:

  • Must have staked LP tokens to unstake

  • Requires gas in native token

  • Can claim rewards in same transaction

  • Unstaking stops reward accumulation

  • Transaction irreversible once confirmed

PARAMETERS:

  • chain: EVM chain to execute on (required)

    • Farm must be deployed on this chain

    • Requires gas in native token

  • protocol: Yield farming protocol (required)

    • Must match original staking protocol

    • Examples: "uniswap", "sushiswap", "curve"

  • amount: Amount of LP tokens to unstake (required)

    • Human-readable format: "100" = 100 LP tokens

    • Must have sufficient staked balance

    • Use "max" or full amount to unstake all

  • privateKey: Transaction signer's private key (required, KEEP SECRET)

    • Must be address that staked LP tokens

    • Never expose, share, or log

  • poolId: Pool/Farm ID (optional)

    • Required for protocols with multiple farms

    • Must match original staking poolId

  • claimRewards: Also claim pending rewards (optional, default: true)

    • true: Withdraw LP tokens AND claim rewards

    • false: Just withdraw LP tokens, leave rewards

EXAMPLES: ✅ Unstake LP tokens and claim rewards: {chain: "polygon", protocol: "sushiswap", amount: "100", privateKey: "0xac0974...", poolId: 0, claimRewards: true}

✅ Unstake without claiming rewards: {chain: "ethereum", protocol: "curve", amount: "50.5", privateKey: "0x...", claimRewards: false}

✅ Emergency unstake all: {chain: "bsc", protocol: "pancakeswap", amount: "max", privateKey: "0x...", poolId: 12}

❌ Invalid - insufficient staked balance: {amount: "1000"} // Only have 100 LP tokens staked

❌ Invalid - wrong poolId: {chain: "polygon", protocol: "sushiswap", amount: "100", privateKey: "0x...", poolId: 99} // Pool doesn't exist

SUPPORTED EVM CHAINS (7 networks): • ethereum (Sepolia) - EIP-1559 enabled, ~12s blocks, moderate gas costs • polygon (Amoy) - Low fees, fast finality (~2s), layer 2 • avalanche (Fuji C-Chain) - Sub-second finality, dynamic fees • bsc (BNB Testnet) - 3s blocks, low gas costs, Binance ecosystem • arbitrum (Sepolia) - Optimistic rollup, low fees, Ethereum security • base (Sepolia) - Coinbase layer 2, EIP-1559, low fees • worldchain (World Sepolia) - World Network testnet, EIP-1559

CRITICAL GAS CONSIDERATIONS:

  • Ethereum: High gas costs, use gas oracle for timing

  • Polygon/BSC: Very low gas, safe for frequent transactions

  • Arbitrum/Base: L2 optimizations, ~10-50x cheaper than Ethereum

  • Avalanche: Dynamic fees, can spike during congestion

  • Always check gas price before executing transactions

TESTNET TOKENS: All chains use testnet tokens with NO REAL VALUE. Faucets available for all supported networks.

OUTPUT STRUCTURE: • success: Boolean indicating unstaking success • transactionHash: Transaction hash for tracking • lpTokenUnstaked: Amount of LP tokens withdrawn • rewardsClaimed: Rewards claimed (if claimRewards=true) • remainingStaked: Remaining staked balance • gasUsed: Gas consumed • executionTime: Time taken in milliseconds

COMMON MISTAKES:

  • Not having gas for transaction

  • Wrong poolId for farm

  • Unstaking when better to compound

  • Emergency withdraw loses pending rewards

  • Not tracking unstaked LP tokens

USE CASES:

  • Exit farming position

  • Rebalance across farms

  • Withdraw liquidity

  • Take profits from farming

  • Move to better yield opportunities

SUPPORTED PROTOCOLS:

  • Uniswap: V2 and V3 farming

  • SushiSwap: MasterChef farms

  • Curve: Gauge staking

  • QuickSwap: Dragon's Lair

  • TraderJoe: MasterChef farms

  • PancakeSwap: Syrup pools

  • And more (see evm_stake_lp for full list)

WITHDRAWAL METHODS:

  • withdraw(poolId, amount): Standard withdrawal + rewards

  • exit(): Withdraw all + claim all rewards

  • unstake(amount): Just unstake, no rewards

  • emergencyWithdraw(poolId): Forfeit rewards, just get LP tokens

GAS COSTS:

  • Simple unstake: 80,000-100,000 gas

  • Unstake + claim: 120,000-150,000 gas

  • Ethereum Sepolia: ~0.002-0.003 ETH

  • Polygon: ~0.00005 POL

  • BSC: ~0.0001 BNB

REWARDS HANDLING:

  • claimRewards=true: Transfers rewards to wallet

  • claimRewards=false: Rewards stay in farm (claim later)

  • Emergency withdrawal: Forfeits all pending rewards

TIMING CONSIDERATIONS:

  • Check reward amount before unstaking

  • Consider gas costs vs reward value

  • May want to compound before unstaking

  • Some farms have unstaking cooldowns

Running on Linux.

LINUX-SPECIFIC NOTES:

  • Package manager: apt (Ubuntu/Debian), yum (RHEL/CentOS), or pacman (Arch)

  • Python 3 is typically 'python3' command

  • GNU tools are standard

  • Use 'xdg-open' command to open files/applications

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "chain": "<chain>",
      "protocol": "<protocol>",
      "amount": "<amount>",
      "privateKey": "<privateKey>"
    },
    "name": "evm_unstake_lp"
  }
}

Input Schema

NameRequiredDescriptionDefault
chainYesEVM chain to execute on
amountYesAmount of LP tokens to unstake
poolIdNoPool/Farm ID
protocolYesYield farming protocol
privateKeyYesPrivate key for transaction
claimRewardsNoAlso claim pending rewards (default: true)

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv1.0.0

TDQS

A4.1/5.0
Behavior4/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full burden and does well: it discloses irreversibility, gas requirements, reward-accumulation stop, claim behavior, and output fields. The 'Emergency unstake all' example uses amount 'max' with default claimRewards=true, which conflicts with the stated emergencyWithdraw forfeiture, and the listed withdrawal methods do not map cleanly to the exposed parameters.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness2/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The core purpose and critical rules are front-loaded, but the definition is massively overlong, repeating gas and reward guidance across multiple sections. The trailing Linux package-manager notes are entirely irrelevant to an EVM unstaking tool and should be removed.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a complex, irreversible financial mutation with no output schema, the description covers prerequisites, gas, supported chains, protocols, reward handling, output shape, and common failure modes. It is complete enough for an agent to call correctly, aside from the noted emergency-withdraw ambiguity.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters5/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema coverage is 100%, but the description still adds substantial meaning: amount accepts human-readable values and 'max', privateKey must belong to the staker and stay secret, poolId is required for multi-farm protocols, and claimRewards defaults to true. This goes well beyond the terse schema descriptions.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening sentence gives a specific verb and resource (unstake LP tokens) and states the optional reward claim. It does not explicitly route the agent away from claim-only or compound siblings, so it stops short of full sibling differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Use cases, common mistakes, and timing notes give clear context for when to unstake. However, alternatives such as evm_claim_farming_rewards or evm_compound_rewards are never named as the correct choice in specific scenarios, leaving some routing to inference.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Deploy Server

Other Tools