balancer-liquidity
Balancer liquidity
Produce a generation-specific liquidity plan with queried BPT or token limits. Balancer V2, V3 and CoW AMM pools can share SDK tooling while using different contracts and liquidity mechanics.
Identify the pool and inventory
Collect chain, pool address/ID, owner, deposit or exit intent, amount vector and accepted slippage. Read the exact pool generation, token order, decimals, pool type and vault/router identities. For boosted pools identify the underlying and wrapped claim; for hooks record the actual hook and supported query behavior. Verify current deployment code, paused/recovery state and the user's BPT custody, including gauges or external wrappers.
Use Balancer API pool data and onchain queries as described in reads. Balancer deprecated @balancer/sdk on 2026-10-28 and it receives no further updates: use it only at a pinned, reviewed version, and treat the onchain query result as authoritative when the two disagree. Keep one block/time context for the comparison. API metadata does not prove the pool is currently operable.
Query before construction
For deposits choose the documented liquidity kind: unbalanced, proportional or single-token, as supported by that pool. Query exact amounts and sender/recipient context, not an arbitrary address. Record returned BPT and price impact. For exits use the corresponding removal query and preserve which tokens are actually returned.
Derive minimum BPT or minimum token outputs from the user's limit with the SDK's Slippage utility. Slippage.fromPercentage('1') means one percent. For a query of 100 BPT and 1% limit, the floor is 99 BPT, before any different gas currency. Do not subtract fees already incorporated in the query twice.
Inspect the unsigned handoff
Return router, calldata, native value, token allowances, permit terms, recipient and calculated minima. Permit2 signing is an authorization action; do not call signing helpers merely to obtain a quote. Check that generation, hook data, token order and all addresses agree with the query. A V2 pool cannot use a V3 vault because the latter is newer.