pub async fn open_full_range_position_instructions(
    rpc: &RpcClient,
    pool_address: Pubkey,
    param: IncreaseLiquidityParam,
    slippage_tolerance_bps: Option<u16>,
    funder: Option<Pubkey>,
) -> Result<OpenPositionInstruction, Box<dyn Error>>
Expand description

Opens a full-range position in a liquidity pool.

This function creates a new position within the full price range for the specified pool, which is ideal for full-range liquidity provisioning, such as in Splash Pools.

§Arguments

  • rpc - A reference to the Solana RPC client.
  • pool_address - The public key of the liquidity pool.
  • param - Parameters for increasing liquidity, specified as IncreaseLiquidityParam.
  • slippage_tolerance_bps - An optional slippage tolerance in basis points. Defaults to the global slippage tolerance if not provided.
  • funder - An optional public key of the funder account. Defaults to the global funder if not provided.

§Returns

Returns a Result containing an OpenPositionInstruction on success, which includes:

  • position_mint - The mint address of the position NFT.
  • quote - The computed liquidity quote, including liquidity delta, token estimates, and maximum tokens.
  • instructions - A vector of Instruction objects required for creating the position.
  • additional_signers - A vector of Keypair objects for additional transaction signers.
  • initialization_cost - The cost of initializing the position, in lamports.

§Errors

Returns an error if:

  • The funder account is invalid.
  • The pool or token mint accounts are not found or invalid.
  • Any RPC request fails.

§Example

use solana_client::rpc_client::RpcClient;
use solana_sdk::{pubkey::Pubkey, signer::Keypair};
use orca_whirlpools::{open_full_range_position_instructions, IncreaseLiquidityParam};
use std::str::FromStr;

set_whirlpools_config_address(WhirlpoolsConfigInput::SolanaDevnet).unwrap();
let rpc = RpcClient::new("https://api.devnet.solana.com");

let whirlpool_pubkey = Pubkey::from_str("WHIRLPOOL_ADDRESS").unwrap();;
let param = IncreaseLiquidityParam::TokenA(1_000_000);
let slippage_tolerance_bps = Some(100);

let wallet = Keypair::new();
let funder = Some(wallet.pubkey());

let result = open_full_range_position_instructions(
    &rpc,
    whirlpool_pubkey,
    param,
    slippage_tolerance_bps,
    funder,
).unwrap();

println!("Position Mint: {:?}", result.position_mint);
println!("Initialization Cost: {} lamports", result.initialization_cost);