/balancer-v3:balancer-v3-architecturefrom balancer-v3
This skill should be used when the user asks about "Balancer V3 architecture", "Vault design", "transient accounting", "unlock pattern", "credit/debt system", "Balancer V3 overview", or needs high-level understanding of how Balancer V3 works.
Ships in balancer-v3. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Balancer V3 is a complete rewrite of the Balancer protocol, featuring a singleton Vault design with transient accounting for gas-efficient operations.
All liquidity in Balancer V3 is managed by a single Vault contract:
┌─────────────────────────────────────────────────────────────┐
│ VAULT │
│ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ │
│ │ Pool A │ │ Pool B │ │ Pool C │ │
│ │ (Weighted) │ │ (Stable) │ │ (Custom) │ │
│ └─────────────┘ └─────────────┘ └─────────────┘ │
│ │
│ Token Reserves: All ERC20 balances held centrally │
│ Pool Accounting: Per-pool balance tracking │
└─────────────────────────────────────────────────────────────┘
| Contract | Purpose |
|---|---|
| Vault | Main entry point. Core swap/liquidity operations. Inherits VaultCommon + Proxy pattern. |
| VaultExtension | Less frequently used functions (pool registration, queries). Delegate-called via Proxy. |
| VaultAdmin | Permissioned administrative functions. |
| Router | User-facing entry point. Handles ETH, Permit2, unlocking. |
unlock() callbackInstead of transferring tokens on each swap, V3 tracks credits and debts:
// During an unlock session:
// 1. Operations create credits (tokens owed TO user) and debts (tokens owed BY user)
// 2. At session end, all deltas must net to zero
// 3. Only then do actual token transfers occur
function unlock(bytes calldata data) external transient returns (bytes memory result) {
// Callback to msg.sender with data
return (msg.sender).functionCall(data);
}
// The transient modifier ensures:
// - Sets isUnlocked = true
// - After callback, checks nonZeroDeltaCount == 0
// - Reverts with BalanceNotSettled() if unsettled
// Give credit to caller (tokens owed TO them)
function _supplyCredit(IERC20 token, uint256 amount) internal;
// Take debt from caller (tokens owed BY them)
function _takeDebt(IERC20 token, uint256 amount) internal;
// Settle debt by transferring tokens to Vault
function settle(IERC20 token, uint256 amountHint) external returns (uint256 credit);
// Claim credit by receiving tokens from Vault
function sendTo(IERC20 token, address to, uint256 amount) external;
enum TokenType {
STANDARD, // No rate provider, 1:1 value
WITH_RATE // Has rate provider for yield-bearing or wrapped tokens
}
struct TokenConfig {
IERC20 token;
TokenType tokenType;
IRateProvider rateProvider; // For WITH_RATE tokens
bool paysYieldFees; // Yield fees charged on this token
}
All internal math uses 18-decimal precision ("scaled18"):
struct PoolData {
IERC20[] tokens;
uint256[] balancesRaw; // Native decimals
uint256[] balancesLiveScaled18; // 18 decimals, rate-adjusted
uint256[] tokenRates; // Rate provider values or FP(1)
uint256[] decimalScalingFactors; // 10^(18 - decimals)
}
Pools are separate contracts that implement IBasePool:
interface IBasePool {
// Core swap math - called by Vault
function onSwap(PoolSwapParams memory request) external returns (uint256);
// Invariant calculation for add/remove liquidity
function computeInvariant(uint256[] memory balancesLiveScaled18, Rounding rounding)
external view returns (uint256);
// Balance computation for single-token operations
function computeBalance(
uint256[] memory balancesLiveScaled18,
uint256 tokenInIndex,
uint256 invariantRatio
) external view returns (uint256 newBalance);
}
Each pool has its own ERC20 token (BPT - Balancer Pool Token):
V3 supports efficient wrapped token operations via buffers:
// Buffers hold underlying + wrapped token reserves
// Enables wrap/unwrap without external calls when liquidity available
function erc4626BufferWrapOrUnwrap(BufferWrapOrUnwrapParams memory params) external;
// Pool state
mapping(address pool => PoolConfigBits) internal _poolConfigBits;
mapping(address pool => IERC20[]) internal _poolTokens;
mapping(address pool => mapping(uint256 index => bytes32)) internal _poolTokenBalances;
// Token reserves (total Vault balance per token)
mapping(IERC20 token => uint256) internal _reservesOf;
// ERC4626 buffers
mapping(IERC4626 => bytes32 packedBalance) internal _bufferTokenBalances;
For deeper understanding, see these related skills:
| Skill | Topic |
|---|---|
balancer-v3-vault | Detailed Vault operations (swap, add/remove liquidity) |
balancer-v3-pools | Pool registration and initialization |
balancer-v3-weighted-pool | Weighted Pool math and factory |
balancer-v3-router | Router patterns and user interaction |
balancer-v3-hooks | Hook system for pool customization |
What SKILL.md sets; muted values are Claude Code's defaults
10 skills in this plugin
/balancer-v3-cow-poolBalancer V3 CoW PoolThis skill should be used when the user asks about "CoW pool", "CoW AMM", "MEV protection", "CowPoolFactory", "CowRouter", "trusted router", "batch auction", or needs to understand Balancer V3 CoW Pool implementation for MEV-protected trading./balancer-v3-gyro-poolBalancer V3 Gyro PoolThis skill should be used when the user asks about "Gyro pool", "2-CLP", "E-CLP", "concentrated liquidity", "sqrtAlpha", "sqrtBeta", "ellipse curve", "Gyroscope", "pricing range", or needs to understand Balancer V3 Gyro Pool implementations./balancer-v3-hooksBalancer V3 HooksThis skill should be used when the user asks about "Balancer hooks", "IHooks", "BaseHooks", "onBeforeSwap", "onAfterSwap", "dynamic swap fee", "hook adjusted amounts", "pool customization", or needs to understand the Balancer V3 hooks system./balancer-v3-poolsBalancer V3 Pool RegistrationThis skill should be used when the user asks about "register pool Balancer", "pool initialization", "TokenConfig", "PoolRoleAccounts", "LiquidityManagement", "BasePoolFactory", "pool configuration", or needs to understand how pools are registered and initialized in Balancer V3./balancer-v3-reclamm-poolBalancer V3 RECLAMM PoolThis skill should be used when the user asks about "RECLAMM", "ReClammPool", "regenerating concentrated liquidity", "virtual balances", "price range tracking", "centeredness", "dailyPriceShiftExponent", "price ratio update", or needs to understand Balancer V3 RECLAMM Pool implementation./balancer-v3-routerBalancer V3 RouterThis skill should be used when the user asks about "Balancer Router", "IRouter", "RouterHooks", "swapSingleTokenExactIn", "addLiquidityProportional", "removeLiquidityProportional", "Permit2 Balancer", "wethIsEth", or needs to understand how users interact with Balancer V3 via routers.balancer-v3@cyotee is listed by cyotee/cyotee-claude-plugins — review the source before installing
npx claudepluginhub cyotee/cyotee-claude-plugins --plugin balancer-v3