Documentation
    Preparing search index...

    Function openPositionInstructions

    • Opens a new position in a concentrated liquidity pool within a specific price range. This function allows you to provide liquidity for the specified range of prices and adjust liquidity parameters accordingly.

      Note: This function cannot be used with Splash Pools.

      Parameters

      • rpc: Rpc<
            GetAccountInfoApi & GetMultipleAccountsApi & GetMinimumBalanceForRentExemptionApi & GetEpochInfoApi,
        >

        A Solana RPC client used to interact with the blockchain.

      • poolAddress: Address

        The address of the liquidity pool where the position will be opened.

      • param: IncreaseLiquidityQuoteParam

        The parameters for increasing liquidity, where you must choose one (liquidity, tokenA, or tokenB). The SDK will compute the other two.

      • lowerPrice: number

        The lower bound of the price range for the position.

      • upperPrice: number

        The upper bound of the price range for the position.

      • OptionalslippageToleranceBps: number = SLIPPAGE_TOLERANCE_BPS

        The slippage tolerance for adding liquidity, in basis points (BPS).

      • Optionalfunder: TransactionSigner = FUNDER

        The account funding the transaction.

      Returns Promise<OpenPositionInstructions>

      A promise that resolves to an object containing instructions, quote, position mint address, and initialization costs for increasing liquidity.

      import { openPositionInstructions, setWhirlpoolsConfig } from '@orca-so/whirlpools';
      import { generateKeyPairSigner, createSolanaRpc, devnet, address } from '@solana/kit';

      await setWhirlpoolsConfig('solanaDevnet');
      const devnetRpc = createSolanaRpc(devnet('https://api.devnet.solana.com'));
      const wallet = await generateKeyPairSigner(); // CAUTION: This wallet is not persistent.

      const whirlpoolAddress = address("POOL_ADDRESS");

      const param = { tokenA: 1_000_000n };
      const lowerPrice = 0.00005;
      const upperPrice = 0.00015;

      const { quote, instructions, initializationCost, positionMint } = await openPositionInstructions(
      devnetRpc,
      whirlpoolAddress,
      param,
      lowerPrice,
      upperPrice,
      100,
      wallet
      );