# Open position and add liquidity

Before you want to deposit liquidity, you need to choose an appropriate price range (corresponding to the tick range) to open a position. In most cases, opening a position and adding liquidity are supposed to be done simultaneously.

**Function input params**

* pool\_id: The object id about which pool you want to operation.
* tick\_lower: Represents the index of the lower tick boundary.
* tick\_upper: Represents the index of the upper tick boundary.
* fix\_amount\_a: true means fixed coinA amount, false means fixed coinB amount
* offer\_amount\_a:If fixed amount A, you must set amountA, amountB will be auto calculated by ClmmPoolUtil.estLiquidityAndcoinAmountFromOneAmounts().
* offer\_amount\_b: f fixed amount B, you must set amountB, amountA will be auto calculated by ClmmPoolUtil.estLiquidityAndcoinAmountFromOneAmounts().

**Example**

```typescript
const pool = await sdk.Pool.getPool(poolAddress)
const fix_amount_a = true
const coin_amount = '1000000'
//Price slippage point.
const slippage = 0.1
const curSqrtPrice = new BN(pool.current_sqrt_price)
const tick_lower = TickMath.getPrevInitializableTickIndex(pool.current_tick_index, Number(pool.tick_spacing))
const tick_upper = TickMath.getNextInitializableTickIndex(pool.current_tick_index, Number(pool.tick_spacing))

const liquidityInput = ClmmPoolUtil.estLiquidityAndcoinAmountFromOneAmounts(
    tick_lower,
    tick_upper,
    new BN(coin_amount),
    fix_amount_a,
    true,
    slippage,
    curSqrtPrice
)

const amount_a = fix_amount_a ? coin_amount : liquidityInput.tokenMaxA.toString()
const amount_b = fix_amount_a ? liquidityInput.tokenMaxB.toString() : coin_amount

// Define parameters for opening position and adding liquidity
const params: OpenPositionWithLiquidityParams = {
    pool_id: pool.pool_address,
    tick_lower,
    tick_upper,
    fix_amount_a,
    offer_amount_a: amount_a,
    offer_amount_b: amount_b
}

const payload = sdk.Position.addLiquidityPaylod(params)
const respone = await executeTransaction([payload], sdk, key, true)
```
