Function open_position_instructions_with_tick_bounds
pub async fn open_position_instructions_with_tick_bounds(
rpc: &RpcClient,
pool_address: Address,
lower_tick_index: i32,
upper_tick_index: i32,
param: IncreaseLiquidityParam,
config: OpenPositionWithTickBoundsConfig,
) -> Result<OpenPositionInstruction, Box<dyn Error>>Expand description
Opens a position in a liquidity pool using explicit tick-index bounds.
This function creates a new position for the specified pool using the provided
lower_tick_index and upper_tick_index bounds (instead of floating-point prices).
The tick indexes must be within Whirlpool’s global bounds and aligned with the pool’s
tick spacing.
§Arguments
rpc- A reference to the Solana RPC client.pool_address- The public key of the liquidity pool.lower_tick_index- The lower tick bound for the position. Must be in bounds and aligned with tick spacing.upper_tick_index- The upper tick bound for the position. Must be in bounds and aligned with tick spacing.param- Maximum amounts of token A and B to deposit.config- The parameters to build the open position with tick bounds instruction.
§Returns
Returns a Result containing an OpenPositionInstruction on success, which includes:
position_mint- The mint address of the position NFT.instructions- A vector ofInstructionobjects required for creating the position.additional_signers- A vector ofKeypairobjects for additional transaction signers.initialization_cost- The cost of initializing the position, in lamports.
§Errors
Returns an error if:
- The pool or token mint accounts are not found or invalid.
- Any RPC request fails.
- The pool is a Splash Pool, as they only support full-range positions.
lower_tick_indexorupper_tick_indexis out of bounds.lower_tick_indexorupper_tick_indexis not aligned with the pool’s tick spacing.lower_tick_indexis greater than or equal toupper_tick_index.
§Example
use solana_client::rpc_client::RpcClient;
use solana_keypair::Keypair;
use solana_pubkey::Pubkey;
use orca_whirlpools::{
open_position_instructions_with_tick_bounds, IncreaseLiquidityParam,
OpenPositionWithTickBoundsConfig, WhirlpoolDeployment
};
use std::str::FromStr;
let rpc = RpcClient::new("https://api.devnet.solana.com");
let whirlpool_pubkey = Pubkey::from_str("WHIRLPOOL_ADDRESS").unwrap();
let param = IncreaseLiquidityParam { token_max_a: 1_000_000, token_max_b: 1_000_000 };
let wallet = Keypair::new();
let config = OpenPositionWithTickBoundsConfig {
slippage_tolerance_bps: Some(100),
funder: Some(wallet.pubkey()),
whirlpool_deployment: Some(WhirlpoolDeployment::devnet()),
};
let result = open_position_instructions_with_tick_bounds(
&rpc, whirlpool_pubkey, -44320, -22160, param, config
).unwrap();
println!("Position Mint: {:?}", result.position_mint);
println!("Initialization Cost: {} lamports", result.initialization_cost);