Function increase_liquidity_instructions
pub async fn increase_liquidity_instructions(
rpc: &RpcClient,
position_mint_address: Address,
param: IncreaseLiquidityParam,
config: IncreaseLiquidityConfig,
) -> Result<IncreaseLiquidityInstruction, Box<dyn Error>>Expand description
Generates instructions to increase liquidity for an existing position.
This function creates instructions to add liquidity to an existing pool position, specified by the position’s mint address, using the provided token max amounts.
§Arguments
rpc- A reference to a Solana RPC client for fetching necessary accounts and pool data.position_mint_address- The public key of the NFT mint address representing the pool position.param- Maximum amounts of token A and B to deposit. The program will use the minimum liquidity achievable within these caps.config- The parameters to build the increase liquidity instruction.
§Returns
A Result containing IncreaseLiquidityInstruction on success:
instructions- A vector ofInstructionobjects required to execute the liquidity addition.additional_signers- A vector ofKeypairobjects representing additional signers required for the instructions.
§Errors
This function will return an error if:
- The
authorityaccount is invalid or missing. - The position or token mint accounts are not found or have invalid data.
- Any RPC request to the blockchain fails.
§Example
use orca_whirlpools::{
increase_liquidity_instructions, IncreaseLiquidityConfig, IncreaseLiquidityParam, WhirlpoolDeployment
};
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_pubkey::Pubkey;
use std::str::FromStr;
use crate::utils::load_wallet;
#[tokio::main]
async fn main() {
let rpc = RpcClient::new("https://api.devnet.solana.com".to_string());
let wallet = load_wallet();
let position_mint_address = Pubkey::from_str("HqoV7Qv27REUtmd9UKSJGGmCRNx3531t33bDG1BUfo9K").unwrap();
let param = IncreaseLiquidityParam { token_max_a: 1_000_000, token_max_b: 1_000_000 };
let config = IncreaseLiquidityConfig {
slippage_tolerance_bps: Some(100),
authority: Some(wallet.pubkey()),
whirlpool_deployment: Some(WhirlpoolDeployment::devnet()),
};
let result = increase_liquidity_instructions(&rpc, position_mint_address, param, config)
.await
.unwrap();
println!("Number of Instructions: {}", result.instructions.len());
}