Skip to main content
Calls to exitPool() must be made on the BEX Vault contract. You cannot send this command directly to a pool.

exitPool function

Arguments explained

ExitPoolRequest struct

Token ordering

When providing assets, tokens must be sorted numerically by address. The values in minAmountsOut correspond to the same index in assets, so these arrays must be created in parallel after sorting.

Minimum amounts

The minAmountsOut parameter sets lower limits for tokens to receive. This protects against price changes between transaction submission and execution. Best practice:
  1. Use queryExit to calculate current token amounts you’ll receive
  2. Apply a slippage tolerance (e.g., multiply by 0.99 for 1% slippage)
  3. Use these adjusted amounts as minAmountsOut

userData encoding

The userData field encodes the exit type and parameters. Different pool types support different exit kinds.
When encoding userData for pools that include their own LP token as part of the pool’s tokens, the LP tokens are not included in the userData.

ExitKind enum

Exit types explained

userData encoding

Examples

Example 1: Single asset exit (EXACT_LP_IN_FOR_ONE_TOKEN_OUT)

Exit a $BERA/$HONEY pool to receive only $BERA:

Example 2: Proportional exit (EXACT_LP_IN_FOR_TOKENS_OUT)

Exit a $BERA/$HONEY pool proportionally:

Example 3: Custom exit (LP_IN_FOR_EXACT_TOKENS_OUT)

Exit a $BERA/$HONEY/$DAI pool for specific token amounts: