Providing Liquidity
Liquidity providers (LPs) deposit tokens into Risk Marketplace pools and receive pool shares (BPT - Balancer Pool Tokens) representing their proportional ownership. LPs earn LP fees generated by trading activity in the pool.
Pool Shares
When providing liquidity, users receive pool shares calculated based on their contribution relative to the existing pool value. These shares:
Represent proportional ownership of all tokens in the pool
Accumulate value as LP fees are retained in the pool
Can be redeemed for underlying tokens at any time (subject to circuit breakers)
1. Joining a Pool
1 a) Proportional Join (Multi-Asset Deposit)
Deposit all pool tokens in their current ratio. This method incurs no LP fees since it maintains pool balance.
Calculation:
Where:
= Pool shares to receive
= Current total pool shares
= Current balance of token (i)
Key Functions
joinPool Method: Handles depositing multiple tokens proportionally in exchange for pool shares.
Parameters:
poolAmountOut:The amount of pool shares to receivemaxAmountsIn[]: Maximum amounts of each token willing to deposit (slippage protection)
Process
Ratio Calculation
The system calculates the ratio of requested pool shares to total supply.
This ratio determines how much of each token is required
Token Transfer
For each token in the pool, the required amount is calculated:
tokenAmountIn = ratio × tokenBalance.Tokens are transferred from the user to the pool; If any calculated amount exceeds
maxAmountsIn, the transaction reverts
Share Minting
Pool shares are minted to the user equal to
poolAmountOut
Example: A pool contains 1,000 ETH and 2,000,000 USDC with 100 BPT total supply. To receive 10 BPT (10% of supply):
ETH required: 10% × 1,000 = 100 ETH
USDC required: 10% × 2,000,000 = 200,000 USDC
1 b) Single-Asset Join (Single Token Deposit)
Deposit only one token. A portion of your deposit is implicitly swapped to acquire the other pool tokens, incurring a LP fee on that portion.
Pool Shares Received:
Where:
= Amount of token deposited
= Current balance of deposit token
= Normalized weight of deposit token
= Dynamic LP fee
Key Functions
joinswapExternAmountIn Method: Deposit an exact amount of one token, receive calculated pool shares.
Parameters:
tokenIn: Address of the token being depositedtokenAmountIn: Exact amount of tokens to depositminPoolAmountOut: Minimum pool shares to receive (slippage protection)
joinswapPoolAmountOut Method: Specify exact pool shares desired, system calculates required deposit.
Parameters:
tokenIn: Address of the token being depositedpoolAmountOut: Exact amount of pool shares to receivemaxAmountIn: Maximum tokens willing to deposit (slippage protection)
Process
Pool Shares Calculation
Uses weighted math to determine fair pool share output
Accounts for the implicit swap and associated fees
Execution
Tokens transferred from user to pool
Pool shares minted to user
Fee Logic: Only the portion that "rebalances" the pool pays the LP fee. If a token has 25% weight, depositing that token implicitly trades 75% of it for other tokens—only that 75% incurs fees (see below example).
Example: Single-asset join with 1,000 USDC into a pool where USDC has 20% weight and LP fee is 0.3%:
Implicit swap portion: 80% × 1,000 = 800 USDC
Fee applied: 0.3% × 800 = 2.4 USDC effective fee
Net contribution used for share calculation: ~997.6 USDC equivalent
2. Exiting a Pool
2 a) Proportional Exit (Multi-Asset Withdrawal)
Redeem pool shares for all tokens proportionally. This method incurs no LP fees.
Calculation:
Where:
= Pool shares being redeemed
= Current total pool shares
= Current balance of token (i)
Key Functions
exitPool Method: Burn pool shares and receive all underlying tokens proportionally.
Parameters:
minAmountsOut: Minimum amounts of each token to receive (slippage protection)poolAmountIn: Amount of pool shares (BPT) to redeem
Process
Ratio Calculation
The system calculates the ratio of redeemed shares to total supply which determines how much of each token the user receives
Share Burning
Pool shares are pulled from the user's balance and are burned, reducing total supply
Token Distribution
For each token: tokenAmountOut = ratio × tokenBalance and if any calculated amount is below minAmountsOut, the transaction reverts
Tokens are transferred from the pool to the user
Example: Redeeming 10 BPT from a pool with 100 BPT supply, 1,000 ETH, and 2,000,000 USDC:
ETH received: 10% × 1,000 = 100 ETH
USDC received: 10% × 2,000,000 = 200,000 USDC
2 b) Single-Asset Exit (Single Token Withdrawal)
Redeem pool shares for only one token. The other tokens are implicitly sold for your desired token, incurring a LP fee.
Tokens Received:
Where:
= Current balance of withdrawal token
= Normalized weight of withdrawal token
= Pool shares being redeemed
Key Functions
exitswapPoolAmountIn Method: Burn exact pool shares, receive calculated token amount.
Parameters:
poolAmountIn: Exact amount of pool shares to redeemminAmountOut: Minimum tokens to receive (slippage protection)tokenOut: Address of the token to receive
exitswapExternAmountOut Method: Specify exact token amount desired, system calculates shares to burn.
Parameters:
tokenOut: Address of the token to receivetokenAmountOut: Exact amount of tokens to receivemaxPoolAmountIn: Maximum pool shares willing to burn (slippage protection)
Process
Output Calculation
Uses weighted math to determine fair token output.
Execution
Pool shares pulled from user and burned
Requested token transferred from pool to user
Fee Logic: The fee applies to the portion being implicitly swapped. Withdrawing a 20% weight token means 80% of the value comes from selling other tokens—that portion pays the LP fee.
Last updated
