use crate::utils::load_wallet;
use orca_tx_sender::{build_and_send_transaction, get_rpc_client, set_rpc};
use orca_whirlpools::{
increase_liquidity_instructions, IncreaseLiquidityConfig, IncreaseLiquidityParam,
WhirlpoolDeployment,
};
use solana_commitment_config::CommitmentLevel;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::{Keypair, Signer};
use std::str::FromStr;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
set_rpc("https://api.devnet.solana.com").await?;
let rpc = get_rpc_client()?;
let wallet = load_wallet();
// SOL/devUSDC (8UJMatBoKTtA25PAYivhWDzNvTuksHUMeUxf5n1hhY7J)
let position_mint_address =
Pubkey::from_str("8UJMatBoKTtA25PAYivhWDzNvTuksHUMeUxf5n1hhY7J").unwrap();
let increase_param = IncreaseLiquidityParam {
token_max_a: 10_000_000, // 0.01 SOL
token_max_b: 250_000, // 0.25 devUSDC
};
let config = IncreaseLiquidityConfig {
slippage_tolerance_bps: Some(100),
authority: Some(wallet.pubkey()),
whirlpool_deployment: Some(WhirlpoolDeployment::devnet()),
};
let increase_result =
increase_liquidity_instructions(&rpc, position_mint_address, increase_param, config)
.await?;
// The instructions may include new token accounts that need to be created
// and signed for with its corresponding Keypair.
let mut signers_increase: Vec<&Keypair> = vec![&wallet];
signers_increase.extend(increase_result.additional_signers.iter().map(|kp| kp));
println!(
"Number of Instructions: {}",
increase_result.instructions.len()
);
let increase_signature = build_and_send_transaction(
increase_result.instructions,
&signers_increase,
Some(CommitmentLevel::Confirmed),
None, // No address lookup tables
)
.await?;
println!(
"Increase liquidity transaction sent: {}",
increase_signature
);
Ok(())
}