Skip to main content
Calls to joinPool() must be made on the BEX Vault contract. You cannot send this command directly to a pool.
To add liquidity to a pool, you must call the joinPool function on the BEX Vault.

joinPool function

Arguments explained

JoinPoolRequest struct

Token ordering

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

Maximum amounts

The maxAmountsIn parameter sets upper limits for tokens to send. This protects against price changes between transaction submission and execution. Best practice:
  1. Use queryJoin to calculate current token amounts needed
  2. Add slippage tolerance (e.g., multiply by 1.01 for 1% slippage)
  3. Use these adjusted amounts as maxAmountsIn

userData encoding

The userData field encodes the join type and parameters. Different pool types support different join kinds.

JoinKind enum

When encoding userData for pools that include their own LP token, the LP tokens are not included except for INIT joins.

userData encoding

Examples

Example 1: Initial join (INIT)

Seeding a new pool with $BERA and $HONEY:

Example 2: Exact tokens join (EXACT_TOKENS_IN_FOR_LP_OUT)

Joining an existing BERA/HONEY pool:

Example 3: Single token join (TOKEN_IN_FOR_EXACT_LP_OUT)

Joining a $BERA/$HONEY/$DAI pool with only $BERA: