exitPool function
Arguments explained
ExitPoolRequest struct
Token ordering
When providing assets, tokens must be sorted numerically by address. The values inminAmountsOut correspond to the same index in assets, so these arrays must be created in parallel after sorting.
Minimum amounts
TheminAmountsOut parameter sets lower limits for tokens to receive. This protects against price changes between transaction submission and execution.
Best practice:
- Use
queryExitto calculate current token amounts you’ll receive - Apply a slippage tolerance (e.g., multiply by 0.99 for 1% slippage)
- Use these adjusted amounts as
minAmountsOut
userData encoding
TheuserData 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: