Crates.io | valiant_vortex_client |
lib.rs | valiant_vortex_client |
version | 0.1.0 |
created_at | 2025-09-25 05:11:29.442344+00 |
updated_at | 2025-09-25 05:11:29.442344+00 |
description | Rust client to interact with Valiant's on-chain Vortex program. |
homepage | https://valiant.trade |
repository | |
max_upload_size | |
id | 1854208 |
size | 1,853,354 |
This package provides developers with low-level functionalities for interacting with the Vortex Program on Solana. It serves as a foundational tool that allows developers to manage and integrate detailed operations into their Rust projects, particularly those related to Valiant's Vortex Program. This package offers granular control for advanced use cases.
anchor
versions ^0.26
but <0.30
. If you enable the anchor
feature of valiant_vortex_client
in cargo.toml
while using a version of anchor that's ^0.30
in your project, you may need to apply a lockfile patch to switch to a lower version:
cargo update anchor:<current-version> --precise 0.29
solana-program
versions ^1.18.0
but <3.0.0
. By default, Cargo will install the latest version of Solana SDK ^v2
. This can cause dependcy issues when using older versions. To solve this you can apply a lockfile patch with the following command:
cargo update solana-program:<current-version> --precise <required-version>
anchor
and solana-program
, the order of the patches matters. First patch anchor
, then patch solana-program
.cargo add valiant_vortex_client
Here are some basic examples of how to use the package:
To derive a PDA for a Vortex account, you can use the get_vortex_address
PDA utility.
use valiant_vortex_client::get_vortex_address;
use solana_sdk::pubkey::Pubkey;
use std::str::FromStr;
fn main() {
let vortex_config_address = Pubkey::from_str("FcrweFY1G9HJAHG5inkGB6pKg1HZ6x9UC2WioAfWrGkR").unwrap();
let token_mint_a = Pubkey::from_str("So11111111111111111111111111111111111111112").unwrap(); // wSOL
let token_mint_b = Pubkey::from_str("BRjpCHtyQLNCo8gqRUr8jtdAj5AjPYQaoqbvcZiHok1k").unwrap(); // DevUSDC
let tick_spacing = 64;
let (vortex_pda, _bump) = get_vortex_address(&vortex_config_address, &token_mint_a, &token_mint_b, tick_spacing).unwrap();
println!("{:?}", vortex_pda);
}
The following example demonstrates how to create an InitializePool
instruction:
use valiant_vortex_client::{
instructions::InitializePoolV2Builder,
get_fee_tier_address,
get_token_badge_address,
get_vortex_address,
};
use solana_sdk::{
pubkey::Pubkey,
signer::{keypair::Keypair, Signer},
};
use std::str::FromStr;
fn main() {
let vortex_config_address = Pubkey::from_str("FcrweFY1G9HJAHG5inkGB6pKg1HZ6x9UC2WioAfWrGkR").unwrap();
let token_mint_a = Pubkey::from_str("So11111111111111111111111111111111111111112").unwrap(); // wSOL
let token_mint_b = Pubkey::from_str("BRjpCHtyQLNCo8gqRUr8jtdAj5AjPYQaoqbvcZiHok1k").unwrap(); // DevUSDC
let (token_badge_a, _bump) = get_token_badge_address(&vortex_config_address, &token_mint_a).unwrap();
let (token_badge_b, _bump) = get_token_badge_address(&vortex_config_address, &token_mint_b).unwrap();
let wallet = Keypair::new(); // CAUTION: this wallet is not persistent
let tick_spacing = 8;
let (vortex_pda, _bump) = get_vortex_address(&vortex_config_address, &token_mint_a, &token_mint_b, tick_spacing).unwrap();
let token_vault_a = Keypair::new();
let token_vault_b = Keypair::new();
let (fee_tier, _bump) = get_fee_tier_address(&vortex_config_address, tick_spacing).unwrap();
let token_program_a = Pubkey::from_str("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA").unwrap();
let token_program_b = Pubkey::from_str("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA").unwrap();
let initial_sqrt_price = 7459106261056563200u128;
let initialize_pool_v2_instruction = InitializePoolV2Builder::new()
.vortex_config(vortex_config_address)
.token_mint_a(token_mint_a)
.token_mint_b(token_mint_b)
.token_badge_a(token_badge_a)
.token_badge_b(token_badge_b)
.funder(wallet.pubkey())
.vortex(vortex_pda)
.token_vault_a(token_vault_a.pubkey())
.token_vault_b(token_vault_b.pubkey())
.fee_tier(fee_tier)
.token_program_a(token_program_a)
.token_program_b(token_program_b)
.tick_spacing(tick_spacing)
.initial_sqrt_price(initial_sqrt_price)
.instruction();
println!("{:?}", initialize_pool_v2_instruction);
}