use crate::utils::load_wallet;
use orca_tx_sender::{build_and_send_transaction, get_rpc_client, set_rpc};
use orca_whirlpools::{
create_concentrated_liquidity_pool_instructions, CreateConcentratedLiquidityPoolConfig,
WhirlpoolDeployment,
};
use solana_commitment_config::CommitmentLevel;
use solana_sdk::{pubkey::Pubkey, signature::Signer, signer::keypair::Keypair};
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();
let token_a = Pubkey::from_str("So11111111111111111111111111111111111111112").unwrap(); // SOL
let token_b = Pubkey::from_str("BRjpCHtyQLNCo8gqRUr8jtdAj5AjPYQaoqbvcZiHok1k").unwrap(); // devUSDC
let tick_spacing = 64;
let config = CreateConcentratedLiquidityPoolConfig {
initial_price: Some(0.01),
funder: Some(wallet.pubkey()),
whirlpool_deployment: Some(WhirlpoolDeployment::devnet()),
};
let result = create_concentrated_liquidity_pool_instructions(
&rpc,
token_a,
token_b,
tick_spacing,
config,
)
.await?;
// The instructions include new Tick Array accounts that need to be created
// and signed for with their corresponding Keypair.
let mut signers: Vec<&Keypair> = vec![&wallet];
signers.extend(result.additional_signers.iter().map(|kp| kp));
println!("Pool Address: {:?}", result.pool_address);
println!(
"Initialization Cost: {} lamports",
result.initialization_cost
);
let signature = build_and_send_transaction(
result.instructions,
&[&wallet],
Some(CommitmentLevel::Confirmed),
None, // No address lookup tables
)
.await?;
println!("Transaction sent: {}", signature);
Ok(())
}