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
| Name | Required | Description | Default |
|---|---|---|---|
| chain | Yes | EVM chain to execute on | |
| amount | Yes | Amount of LP tokens to unstake | |
| poolId | No | Pool/Farm ID | |
| protocol | Yes | Yield farming protocol | |
| privateKey | Yes | Private key for transaction | |
| claimRewards | No | Also claim pending rewards (default: true) |