This request allows the caller to create a position in a pool or, if the pool does not yet exist, to create a new pool. If a new pool must be created, a transaction is returned for the pool creation. In either case, a transaction is returned to create the new position in the pool. If the parameter simulateTransaction is set to true, then the response will include the gas fee for the creation transaction(s).
Different fields are required depending on the pool version (V2, V3, or V4) into which a new position will be created, in addition to the fields which are always required. When creating a position in a V2 pool, the position object must contain token0 and token1 addresses. When creating a position in a V3 pool, the position object must contain all fields except for hooks which are not supported in V3 pools. When creating a position in a V4 pool, all fields within the position object are required except for hooks which is optional. Note that both V3 and V4 pools require the population of tickLower and tickUpper fields. Furthermore, poolLiquidity, currentTick, and sqrtRatioX96 are always required when creating a position in a V3 or V4 pool. All pool versions require the population of amount0 and amount1, which specify the quantity of tokens being entered into the pool.
When creating a pool, additional fields are required depending on the pool version being created, in addition to the fields which are always required. When creating a V3 or V4 pool, either initialPrice or poolLiquidity, currentTick, and sqrtRatioX96 are required. When creating a V2 pool, only initialPrice is required. V3 and V4 pools require amount0 and amount1 fields to be populated, as the creation of the pool must include seeding of liquidity. V2 pools may optionally have amount0 and amount1 populated; V2 pools do not require liquidity to be seeded when creating the pool.