Function create_splash_pool_instructions
pub async fn create_splash_pool_instructions(
rpc: &RpcClient,
token_a: Address,
token_b: Address,
config: CreateSplashPoolConfig,
) -> Result<CreatePoolInstructions, Box<dyn Error>>Expand description
Creates the necessary instructions to initialize a Splash Pool.
§Arguments
rpc- A reference to a Solana RPC client for communicating with the blockchain.token_a- The public key of the first token mint address to include in the pool.token_b- The public key of the second token mint address to include in the pool.config- The parameters to build the create splash pool instruction.
§Returns
A Result containing CreatePoolInstructions on success:
instructions- A vector of Solana instructions needed to initialize the pool.initialization_cost- The estimated rent exemption cost for initializing the pool, in lamports.pool_address- The public key of the newly created pool.additional_signers- A vector ofKeypairobjects representing additional signers required for the instructions.
§Errors
This function will return an error if:
- The funder account is invalid.
- Token mints are not found or have invalid data.
- The token mint order does not match the canonical byte order.
- Any RPC request to the blockchain fails.
§Example
use orca_whirlpools::{create_splash_pool_instructions, CreateSplashPoolConfig, WhirlpoolDeployment};
use solana_client::nonblocking::rpc_client::RpcClient;
use solana_keypair::{Keypair, Signer};
use solana_pubkey::Pubkey;
use std::str::FromStr;
#[tokio::main]
async fn main() {
let rpc = RpcClient::new("https://api.devnet.solana.com".to_string());
let token_a = Pubkey::from_str("So11111111111111111111111111111111111111112").unwrap();
let token_b = Pubkey::from_str("BRjpCHtyQLNCo8gqRUr8jtdAj5AjPYQaoqbvcZiHok1k").unwrap(); // devUSDC
let wallet = Keypair::new(); // CAUTION: This wallet is not persistent.
let config = CreateSplashPoolConfig {
initial_price: Some(0.01),
funder: Some(wallet.pubkey()),
whirlpool_deployment: Some(WhirlpoolDeployment::devnet()),
};
let create_pool_instructions = create_splash_pool_instructions(&rpc, token_a, token_b, config)
.await
.unwrap();
println!("Pool Address: {:?}", create_pool_instructions.pool_address);
println!(
"Initialization Cost: {} lamports",
create_pool_instructions.initialization_cost
);
}