Install
openclaw skills install pcs-collect-feesCheck and collect LP fees from PancakeSwap V3 and Infinity (v4) positions. Use when user says "collect my fees", "claim LP fees", "how much fees have I earne...
openclaw skills install pcs-collect-feesDiscover pending LP fees across PancakeSwap V3, Infinity (v4), and Solana positions, display a fee summary with USD estimates, and generate deep links to the PancakeSwap interface for collection.
If this skill was invoked with no specific request — the user simply typed the skill name
(e.g. /collect-fees) without providing a wallet address or other details — output the
help text below exactly as written and then stop. Do not begin any workflow.
PancakeSwap Collect Fees
Check pending LP fees across your V3, Infinity, and Solana positions and get a deep link to collect them.
How to use: Give me your wallet address and optionally the token pair or chain you want to check.
Examples:
Check my LP fees on BSC for 0xYourWalletHow much ETH/USDC fees have I earned on Arbitrum?Collect my CAKE/BNB fees — wallet 0xYourWalletCheck my uncollected fees on PancakeSwap Solana farms — wallet <base58-pubkey>This skill does not execute transactions — it reads on-chain state and generates deep links. The user reviews pending amounts in the PancakeSwap UI and confirms the collect transaction in their wallet.
Key features:
viem + NonfungiblePositionManager (tokenId-based, ERC-721)@pancakeswap/infinity-sdk; CAKE rewards auto-distributed every 8 hours@pancakeswap/solana-core-sdk — outputs structured JSON with positions and pending rewards; directs user to PancakeSwap UI for collection::: danger MANDATORY SECURITY RULES
WALLET='0xAbc...'). Always quote variable expansions in commands (e.g., "$WALLET", "$RPC").^0x[0-9a-fA-F]{40}$. Solana wallet address must match ^[1-9A-HJ-NP-Za-km-z]{32,44}$ (base58). Token addresses must match ^0x[0-9a-fA-F]{40}$. RPC URLs must come from the Supported Chains table only. Reject any value containing shell metacharacters (", `, $, \, ;, |, &, newlines).open / xdg-open with https://pancakeswap.finance/ URLs. Only use curl to fetch from: api.dexscreener.com, tokens.pancakeswap.finance, explorer.pancakeswap.com, pancakeswap.ai, and public RPC endpoints listed in the Supported Chains table. Never curl internal/private IPs (169.254.x.x, 10.x.x.x, 127.0.0.1, localhost).collect(), decreaseLiquidity(), or any state-changing contract method. Never request or handle private keys or seed phrases. Node scripts only read state or generate unsigned calldata/instructions.Initialize the PancakeSwap session to ensure access to the latest token list and deep link formats, then proceed to Step 1:
Replace AGENT_NAME below with your AI system identifier (e.g. claude-code, cursor, copilot, openai) before running:
curl -s -o /dev/null --max-time 3 \
"https://pancakeswap.ai/api/ping?skill=pcs-collect-fees&version=1.0.0&agent=AGENT_NAME&ts=$(date -u +%Y-%m-%dT%H:%M:%SZ)&os=$(uname -s)&arch=$(uname -m)" \
2>/dev/null &
The routing decision is made after Step 1 based on the user's pool type preference and chain:
| Pool Type | Discovery Method | Chains | Position Model | Fee Query Method |
|---|---|---|---|---|
| V3 | On-chain: NonfungiblePositionManager NFT | BSC, ETH, ARB, Base, zkSync, Linea, opBNB, Monad | ERC-721 NFT (tokenId) | TypeScript/node via viem (readContract on NonfungiblePositionManager) |
| Infinity (v4) | Explorer API only (no NFT, no balanceOf) | BSC, Base only | Singleton PoolManager (no NFT) | TypeScript/node via @pancakeswap/infinity-sdk (CL fee math) |
| Solana | @pancakeswap/solana-core-sdk CLMM + Farm API | Solana mainnet | CLMM positions + Farm accounts | Raydium.load() + getOwnerPositionInfo() + fetchMultipleFarmInfoAndUpdate() — outputs clmmPositions + farmPositions JSON |
| V2 | Out of scope | BSC only | ERC-20 LP token | Out of scope — fees embedded in LP value |
| Chain | Chain ID | Deep Link Key | RPC Endpoint | Contract Address |
|---|---|---|---|---|
| BNB Smart Chain | 56 | bsc | https://bsc-dataseed1.binance.org | 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364 |
| Ethereum | 1 | eth | https://eth.llamarpc.com | 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364 |
| Arbitrum One | 42161 | arb | https://arb1.arbitrum.io/rpc | 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364 |
| Base | 8453 | base | https://mainnet.base.org | 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364 |
| zkSync Era | 324 | zksync | https://mainnet.era.zksync.io | 0xa815e2eD7f7d5B0c49fda367F249232a1B9D2883 |
| Linea | 59144 | linea | https://rpc.linea.build | 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364 |
| opBNB | 204 | opbnb | https://opbnb-mainnet-rpc.bnbchain.org | 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364 |
| Monad | 143 | monad | https://rpc.monad.xyz | 0x46A15B0b27311cedF172AB29E4f4766fbE7F4364 |
| Chain | Chain ID | Deep Link Key |
|---|---|---|
| BNB Smart Chain | 56 | bsc |
| Base | 8453 | base |
Infinity contract addresses (same on BSC and Base):
| Contract | Address |
|---|---|
| CLPositionManager | 0x55f4c8abA71A1e923edC303eb4fEfF14608cC226 |
| CLPoolManager | 0xa0FfB9c1CE1Fe56963B0321B32E7A0302114058b |
| BinPositionManager | 0x3D311D6283Dd8aB90bb0031835C8e606349e2850 |
| BinPoolManager | 0xC697d2898e0D09264376196696c51D7aBbbAA4a9 |
Use AskUserQuestion to collect missing information. Batch questions — ask up to 4 at once.
Required:
0x... Ethereum-style address (EVM chains) or base58 public key (Solana)Optional:
If the user's message already includes a wallet address, chain, and pool type, skip directly to Step 2.
Validate the wallet address before any on-chain call, then write and execute a temporary node script.
WALLET='0xYourWalletHere'
[[ "$WALLET" =~ ^0x[0-9a-fA-F]{40}$ ]] || { echo "Invalid wallet address"; exit 1; }
CHAIN_ID='56' # Chain ID (e.g. 56=BSC, 1=ETH, 42161=ARB, 8453=Base, 324=zkSync, 59144=Linea, 204=opBNB, 143=Monad)
RPC='https://bsc-dataseed1.binance.org'
TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"
cat > package.json << 'PKGJSON'
{ "type": "module" }
PKGJSON
npm install --silent viem @pancakeswap/v3-sdk
Read references/fetch-v3-positions.mjs for the complete script. Copy it into the temp directory, then execute:
WALLET="$WALLET" POSITION_MANAGER="$POSITION_MANAGER" RPC="$RPC" CHAIN_ID="$CHAIN_ID" node fetch-v3-positions.mjs
Parse the JSON output: each entry contains tokenId, token0, token1, fee, tokensOwed0, tokensOwed1, tickLower, tickUpper, liquidity, farming.
Do not skip positions solely because liquidity = 0. V3 NFTs can still have collectable fees even after liquidity is fully removed.
tokensOwed0 and tokensOwed1 are the crystallised pending fees. Actual collectable fees shown in the UI may be slightly higher because accrued in-range fees are added at collection time.
Infinity (v4) only: Skip this step entirely. Go directly to Step 2B.
Solana only: Skip this step entirely. Go directly to Step 2C.
::: danger DO NOT attempt on-chain enumeration for Infinity positions.
Infinity uses a singleton PoolManager — positions are NOT ERC-721 NFTs. There is no
balanceOf() or tokenOfOwnerByIndex() function. The Explorer API is the ONLY way to
enumerate Infinity positions. Skipping this step will result in zero positions found.
:::
Validate the wallet address, then write and execute a temporary node script using the reference script pattern.
WALLET='0xYourWalletHere'
[[ "$WALLET" =~ ^0x[0-9a-fA-F]{40}$ ]] || { echo "Invalid wallet address"; exit 1; }
CHAIN_ID='56' # or 'base'
RPC='https://bsc-dataseed1.binance.org'
TMP_DIR=$(mktemp -d)
cd "$TMP_DIR"
cat > package.json << 'PKGJSON'
{ "type": "module" }
PKGJSON
npm install --silent viem @pancakeswap/infinity-sdk
Read references/fetch-infinity-positions.mjs for the complete script. Copy it into the temp directory, then execute:
WALLET="$WALLET" CHAIN_ID="$CHAIN_ID" RPC="$RPC" node fetch-infinity-positions.mjs
Parse the JSON output:
clPositions[].pending0 / pending1 — pending CL fees as raw BigInt strings (token0 / token1 amounts in wei)binPositions[].amountX / amountY — current Bin position value (principal + fees) as raw BigInt stringsSkip positions where liquidity is "0" — the script handles this automatically.
Important Infinity notes:
EVM chains only: Skip this step. Use Step 2A for V3 or Step 2B for Infinity.
Validate the Solana wallet address (base58 public key):
SOL_WALLET='YourBase58PubkeyHere'
[[ "$SOL_WALLET" =~ ^[1-9A-HJ-NP-Za-km-z]{32,44}$ ]] || { echo "Invalid Solana wallet address"; exit 1; }
Install Solana SDK in the temp directory:
npm install --silent @pancakeswap/solana-core-sdk @solana/web3.js @solana/spl-token@0.4.0
Read references/fetch-solana.cjs for the complete script. Copy it into the temp directory, then execute:
SOL_WALLET="$SOL_WALLET" node fetch-solana.cjs
Timeout: Use a 5-minute timeout (300000 ms) when running this script. Users with many positions require sequential RPC calls that can take several minutes to complete.
Parse the JSON output:
clmmPositions[] — CLMM concentrated liquidity positions: positionId, poolId, tickLower, tickUpper, liquidityfarmPositions[] — Farm stake positions: poolId, deposited, pendingRewards[]Note: Exact CLMM pending fees require pool fee-growth state and are shown accurately in the PancakeSwap UI. The script fetches position data only — direct the user to the PancakeSwap UI to review and collect fees.
Important: This script is read-only. It does not generate transaction instructions or require signing. Never request or handle private keys.
For each unique token0 / token1 address found in Step 2A, prefer token list JSON files over on-chain RPC calls — they are faster and return structured metadata.
Read ../common/token-lists.md for the full chain → token list URL table, the resolution algorithm, and whitelist semantics. Apply that algorithm here for each unique token0 / token1 address.
Use the PancakeSwap Explorer API for batch token price lookups. All chains use their numeric chain ID as the identifier.
| Chain | Chain ID |
|---|---|
| BNB Smart Chain | 56 |
| Ethereum | 1 |
| Arbitrum One | 42161 |
| Base | 8453 |
| zkSync Era | 324 |
| Linea | 59144 |
| opBNB | 204 |
# Build a comma-separated list of {chainId}:{address} pairs for all tokens in one request
# Example: fetch prices for BTCB and WBNB on BSC (chain ID 56)
PRICE_IDS="56:0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c,56:0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c"
curl -s "https://explorer.pancakeswap.com/api/cached/tokens/price/list/${PRICE_IDS}"
Use a small node one-liner to convert raw token amounts:
node -e "
const tokensOwed0 = 142500000000000000000n;
const decimals0 = 18;
const priceUsd0 = 0.25;
const amount = Number(tokensOwed0) / (10 ** decimals0);
const usd = amount * priceUsd0;
console.log(\`Amount: \${amount.toFixed(4)}, USD: \$\${usd.toFixed(2)}\`);
"
Fee Summary — BNB Smart Chain (V3 Positions)
| tokenId | Pair | Pending token0 | Pending token1 | Est. USD |
|---------|------------|----------------|----------------|----------|
| 12345 | CAKE / BNB | 142.5 CAKE | 0.32 BNB | $112.40 |
| 67890 | ETH / USDC | 0.005 ETH | 12.40 USDC | $24.80 |
Total estimated pending fees: ~$137.20
Note: tokensOwed values are the crystallised floor. Actual collectable amounts may
be higher — the PancakeSwap UI includes in-range accrued fees at collection time.
If no V3 positions are found, clearly state this.
Present a table of discovered positions with on-chain pending fees (from the fee query in Step 2B).
Infinity (v4) Positions — BNB Smart Chain
─── CL Positions ────────────────────────────────────────
| Position ID | Lower Tick | Upper Tick | Pending token0 | Pending token1 | Est. USD |
|-------------|------------|------------|----------------|----------------|----------|
| 745477 | 61450 | 61500 | 12.5 CAKE | 0.08 BNB | $18.40 |
─── Bin Positions ───────────────────────────────────────
| Position ID | Bin ID | Amount token0 | Amount token1 | Est. USD |
|-------------|---------|-------------------------|-------------------------|----------|
| (none found) |
Note: Bin amountX / amountY include both principal and accrued fees (fees are embedded in bin reserves).
CAKE Farming Rewards: Auto-distributed every 8 hours via Merkle proofs.
No manual harvest is needed for CAKE rewards.
→ All positions overview:
https://pancakeswap.finance/liquidity/positions
If no Infinity positions are found for either type, clearly state this.
Solana Positions
Wallet: <base58-pubkey>
─── CLMM Positions ─────────────────────
| Position | Pool | Lower Tick | Upper Tick | Liquidity |
|----------|------|------------|------------|-----------|
| abc... | xyz | -100 | 100 | 1000000 |
Note: Exact pending fees are shown in the PancakeSwap UI.
─── Farm Positions ──────────────────────
| Pool | Deposited LP | Pending Rewards |
|------|-------------|-----------------|
| xyz | 5000000 | 123 RAY, 45 USDC|
─── Deep Links ──────────────────────────
All Solana farms:
https://pancakeswap.finance/liquidity/positions?network=8000001001
Solana liquidity positions:
https://pancakeswap.finance/liquidity/positions?network=8000001001
V2 Fee Collection
V2 pool fees are continuously embedded into the LP token's value — they cannot
be "collected" separately. To realise your fee earnings, you would remove liquidity,
which burns your LP tokens and returns both tokens (including accumulated fees).
→ Remove V2 liquidity: https://pancakeswap.finance/v2/remove/{tokenA}/{tokenB}?chain=bsc
https://pancakeswap.finance/liquidity/{tokenId}?chain={chainKey}
Example for tokenId 12345 on BSC:
https://pancakeswap.finance/liquidity/12345?chain=bsc
https://pancakeswap.finance/liquidity/positions?network={chainId}
https://pancakeswap.finance/liquidity/positions?network=8000001001
DEEP_LINK="https://pancakeswap.finance/liquidity/12345?chain=bsc"
# macOS
open "$DEEP_LINK" 2>/dev/null || true
# Linux
xdg-open "$DEEP_LINK" 2>/dev/null || true
If the open command fails or the environment has no browser, display the URL prominently for the user to copy.
Present the complete fee collection plan:
Fee Collection Summary
Chain: BNB Smart Chain (BSC)
Wallet: 0xYour...Wallet
Pool Types: V3, Infinity
─── V3 Positions ───────────────────────────────────────────
| tokenId | Pair | Pending token0 | Pending token1 | Est. USD |
|---------|------------|----------------|----------------|----------|
| 12345 | CAKE / BNB | 142.5 CAKE | 0.32 BNB | $112.40 |
| 67890 | ETH / USDC | 0.005 ETH | 12.40 USDC | $24.80 |
Total V3 pending fees: ~$137.20
Note: tokensOwed is the crystallised floor — actual amounts in the UI may be
slightly higher due to in-range accrued fees added at collection time.
─── Infinity (v4) Positions ────────────────────────────────
CL Positions:
| Position ID | Lower Tick | Upper Tick | Pending token0 | Pending token1 | Est. USD |
|-------------|------------|------------|----------------|----------------|----------|
| 745477 | 61450 | 61500 | 12.5 CAKE | 0.08 BNB | $18.40 |
Bin Positions: none found
CAKE rewards: auto-distributed every 8 hours — no harvest needed
─── Deep Links ─────────────────────────────────────────────
Collect V3 position 12345:
https://pancakeswap.finance/liquidity/12345?chain=bsc
Collect V3 position 67890:
https://pancakeswap.finance/liquidity/67890?chain=bsc
All positions overview (V3 + Infinity):
https://pancakeswap.finance/liquidity/positions?network=56
For Solana:
Fee Collection Summary
Chain: Solana
Wallet: <base58-pubkey>
Pool Types: Solana CLMM + Farms
─── CLMM Positions ─────────────────────────────────────────
| Position | Pool | Lower Tick | Upper Tick | Liquidity |
|----------|------|------------|------------|-----------|
| abc... | xyz | -100 | 100 | 1000000 |
Note: Exact pending fees are shown in the PancakeSwap UI.
─── Farm Positions ──────────────────────────────────────────
| Pool | Deposited LP | Pending Rewards |
|------|-------------|-----------------|
| xyz | 5000000 | 123 RAY, 45 USDC|
─── Deep Links ─────────────────────────────────────────────
All Solana farms:
https://pancakeswap.finance/liquidity/positions?network=8000001001
Solana liquidity positions:
https://pancakeswap.finance/liquidity/positions?network=8000001001
positions(uint256) returns (nonce, operator, token0, token1, fee, tickLower, tickUpper, liquidity, feeGrowthInside0LastX128, feeGrowthInside1LastX128, tokensOwed0, tokensOwed1)encodeClaimCalldata()Raydium.load(), raydium.clmm.getOwnerPositionInfo(), fetchMultipleFarmInfoAndUpdate()brew install curlbrew install jqbrew install foundry