Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4,992 changes: 3,140 additions & 1,852 deletions Cargo.lock

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ members = ["cli", "market_making", "commons", "dlmm_interface"]
resolver = "2"

[workspace.dependencies]
anchor-lang = "0.29.0"
anchor-spl = "0.29.0"
anchor-client = "0.29.0"

solana-sdk = "1.17.0"
spl-associated-token-account = "1"
solana-transaction-status = "1.17.0"
solana-account-decoder = "1.17.0"
spl-memo = "3.0.0"
spl-transfer-hook-interface = "0.5.0"
anchor-lang = "0.31.0"
anchor-spl = "0.31.0"
anchor-client = "0.31.0"

solana-sdk = "2.1.0"
spl-associated-token-account = "6"
solana-transaction-status = "2.1.0"
solana-account-decoder = "2.1.0"
spl-memo = "6.0.0"
spl-transfer-hook-interface = "0.9.0"

serde_json = "1.0.48"
serde = "1.0.104"
Expand Down
4 changes: 2 additions & 2 deletions cli/src/instructions/add_liquidity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub async fn execute_add_liquidity<C: Deref<Target = impl Signer> + Clone>(
// Sort by bin id
bin_liquidity_distribution.sort_by(|a, b| a.0.cmp(&b.0));

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();

let lb_pair_state = rpc_client
.get_account_and_deserialize(&lb_pair, |account| {
Expand Down Expand Up @@ -127,7 +127,7 @@ pub async fn execute_add_liquidity<C: Deref<Target = impl Signer> + Clone>(
if let Some((slices, transfer_hook_remaining_accounts)) =
get_potential_token_2022_related_ix_data_and_accounts(
&lb_pair_state,
program.async_rpc(),
program.rpc(),
ActionType::Liquidity,
)
.await?
Expand Down
11 changes: 7 additions & 4 deletions cli/src/instructions/admin/initialize_permission_lb_pair.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use crate::*;
use anchor_lang::AccountDeserialize;
use anchor_spl::token_interface::Mint;
Expand Down Expand Up @@ -35,9 +37,10 @@ pub async fn execute_initialize_permission_lb_pair<C: Deref<Target = impl Signer
activation_type,
} = params;

let base_keypair = read_keypair_file(base_keypair_path).expect("base keypair file not found");
let base_keypair =
Arc::new(read_keypair_file(base_keypair_path).expect("base keypair file not found"));

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();

let mut accounts = rpc_client
.get_multiple_accounts(&[token_mint_x, token_mint_y])
Expand All @@ -62,7 +65,7 @@ pub async fn execute_initialize_permission_lb_pair<C: Deref<Target = impl Signer
let (lb_pair, _bump) =
derive_permission_lb_pair_pda(base_keypair.pubkey(), token_mint_x, token_mint_y, bin_step);

if program.rpc().get_account_data(&lb_pair).is_ok() {
if program.rpc().get_account_data(&lb_pair).await.is_ok() {
return Ok(lb_pair);
}

Expand Down Expand Up @@ -135,7 +138,7 @@ pub async fn execute_initialize_permission_lb_pair<C: Deref<Target = impl Signer
let request_builder = program.request();
let signature = request_builder
.instruction(init_pair_ix)
.signer(&base_keypair)
.signer(base_keypair.clone())
.send_with_spinner_and_config(transaction_config)
.await;

Expand Down
2 changes: 1 addition & 1 deletion cli/src/instructions/admin/initialize_preset_parameter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub async fn execute_initialize_preset_parameter<C: Deref<Target = impl Signer>
base_fee_power_factor,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();

let preset_parameter_v2_count = rpc_client
.get_program_accounts_with_config(
Expand Down
2 changes: 1 addition & 1 deletion cli/src/instructions/admin/initialize_reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub async fn execute_initialize_reward<C: Deref<Target = impl Signer> + Clone>(
let (reward_vault, _bump) = derive_reward_vault_pda(lb_pair, reward_index);
let (event_authority, _bump) = derive_event_authority_pda();

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();
let reward_mint_account = rpc_client.get_account(&reward_mint).await?;

let (token_badge, _bump) = derive_token_badge_pda(reward_mint);
Expand Down
2 changes: 1 addition & 1 deletion cli/src/instructions/admin/update_base_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub async fn execute_update_base_fee<C: Deref<Target = impl Signer> + Clone>(
base_fee_bps,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();

let pair_account = rpc_client.get_account(&lb_pair).await?;

Expand Down
2 changes: 1 addition & 1 deletion cli/src/instructions/admin/update_reward_duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub async fn execute_update_reward_duration<C: Deref<Target = impl Signer> + Clo
reward_duration,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();
let lb_pair_state = rpc_client
.get_account_and_deserialize(&lb_pair, |account| {
Ok(LbPairAccount::deserialize(&account.data)?.0)
Expand Down
4 changes: 2 additions & 2 deletions cli/src/instructions/admin/withdraw_protocol_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub async fn execute_withdraw_protocol_fee<C: Deref<Target = impl Signer> + Clon
amount_y,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();

let lb_pair_state = rpc_client
.get_account_and_deserialize(&lb_pair, |account| {
Expand Down Expand Up @@ -66,7 +66,7 @@ pub async fn execute_withdraw_protocol_fee<C: Deref<Target = impl Signer> + Clon
if let Some((slices, transfer_hook_remaining_accounts)) =
get_potential_token_2022_related_ix_data_and_accounts(
&lb_pair_state,
program.async_rpc(),
program.rpc(),
ActionType::Liquidity,
)
.await?
Expand Down
4 changes: 2 additions & 2 deletions cli/src/instructions/claim_fee.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pub async fn execute_claim_fee<C: Deref<Target = impl Signer> + Clone>(
) -> Result<()> {
let ClaimFeeParams { position } = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();
let position_state = rpc_client
.get_account_and_deserialize(&position, |account| {
Ok(PositionV2Account::deserialize(&account.data)?.0)
Expand Down Expand Up @@ -98,7 +98,7 @@ pub async fn execute_claim_fee<C: Deref<Target = impl Signer> + Clone>(
if let Some((slices, transfer_hook_remaining_accounts)) =
get_potential_token_2022_related_ix_data_and_accounts(
&lb_pair_state,
program.async_rpc(),
program.rpc(),
ActionType::Liquidity,
)
.await?
Expand Down
4 changes: 2 additions & 2 deletions cli/src/instructions/claim_reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub async fn execute_claim_reward<C: Deref<Target = impl Signer> + Clone>(
position,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();
let (reward_vault, _bump) = derive_reward_vault_pda(lb_pair, reward_index);

let lb_pair_state = rpc_client
Expand Down Expand Up @@ -71,7 +71,7 @@ pub async fn execute_claim_reward<C: Deref<Target = impl Signer> + Clone>(
if let Some((slices, transfer_hook_remaining_accounts)) =
get_potential_token_2022_related_ix_data_and_accounts(
&lb_pair_state,
program.async_rpc(),
program.rpc(),
ActionType::Reward(reward_index as usize),
)
.await?
Expand Down
2 changes: 1 addition & 1 deletion cli/src/instructions/close_position.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub async fn execute_close_position<C: Deref<Target = impl Signer> + Clone>(
) -> Result<()> {
let ClosePositionParams { position } = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();
let position_state = rpc_client
.get_account_and_deserialize(&position, |account| {
Ok(PositionV2Account::deserialize(&account.data)?.0)
Expand Down
4 changes: 2 additions & 2 deletions cli/src/instructions/fund_reward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub async fn execute_fund_reward<C: Deref<Target = impl Signer> + Clone>(
funding_amount,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();

let (reward_vault, _bump) = derive_reward_vault_pda(lb_pair, reward_index);

Expand Down Expand Up @@ -50,7 +50,7 @@ pub async fn execute_fund_reward<C: Deref<Target = impl Signer> + Clone>(
let (event_authority, _bump) = derive_event_authority_pda();

let reward_transfer_hook_accounts =
get_extra_account_metas_for_transfer_hook(reward_mint, program.async_rpc()).await?;
get_extra_account_metas_for_transfer_hook(reward_mint, program.rpc()).await?;

let remaining_accounts_info = RemainingAccountsInfo {
slices: vec![RemainingAccountsSlice {
Expand Down
2 changes: 1 addition & 1 deletion cli/src/instructions/get_all_positions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub async fn execute_get_all_positions<C: Deref<Target = impl Signer> + Clone>(
) -> Result<()> {
let GetAllPositionsParams { lb_pair, owner } = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();

let account_config = RpcAccountInfoConfig {
encoding: Some(UiAccountEncoding::Base64),
Expand Down
4 changes: 2 additions & 2 deletions cli/src/instructions/ilm/remove_liquidity_by_price_range.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub async fn execute_remove_liquidity_by_price_range<C: Deref<Target = impl Sign
max_price,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();

let lb_pair_state = rpc_client
.get_account_and_deserialize(&lb_pair, |account| {
Expand Down Expand Up @@ -106,7 +106,7 @@ pub async fn execute_remove_liquidity_by_price_range<C: Deref<Target = impl Sign
if let Some((slices, remaining_accounts)) =
get_potential_token_2022_related_ix_data_and_accounts(
&lb_pair_state,
program.async_rpc(),
program.rpc(),
ActionType::Liquidity,
)
.await?
Expand Down
6 changes: 3 additions & 3 deletions cli/src/instructions/ilm/seed_liquidity_from_operator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ pub async fn execute_seed_liquidity_by_operator<C: Deref<Target = impl Signer> +
"base_pubkey mismatch"
);

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();

let k = 1.0 / curvature;

Expand Down Expand Up @@ -294,11 +294,11 @@ pub async fn execute_seed_liquidity_by_operator<C: Deref<Target = impl Signer> +
);

let transfer_hook_x_account =
get_extra_account_metas_for_transfer_hook(lb_pair_state.token_x_mint, program.async_rpc())
get_extra_account_metas_for_transfer_hook(lb_pair_state.token_x_mint, program.rpc())
.await?;

let transfer_hook_y_account =
get_extra_account_metas_for_transfer_hook(lb_pair_state.token_y_mint, program.async_rpc())
get_extra_account_metas_for_transfer_hook(lb_pair_state.token_y_mint, program.rpc())
.await?;

let accounts = rpc_client
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use anchor_lang::{prelude::Clock, AccountDeserialize};
use anchor_spl::{
associated_token::get_associated_token_address_with_program_id,
Expand Down Expand Up @@ -59,16 +61,17 @@ pub async fn execute_seed_liquidity_single_bin_by_operator<
selective_rounding,
} = params;

let position_base_kp =
read_keypair_file(base_position_path).expect("position base keypair file not found");
let position_base_kp = Arc::new(
read_keypair_file(base_position_path).expect("position base keypair file not found"),
);

assert_eq!(
position_base_kp.pubkey(),
base_pubkey,
"Invalid position base key"
);

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();
let operator = program.payer();

let lb_pair_state = rpc_client
Expand Down Expand Up @@ -282,7 +285,7 @@ pub async fn execute_seed_liquidity_single_bin_by_operator<
if let Some((slice, transfer_hook_remaining_accounts)) =
get_potential_token_2022_related_ix_data_and_accounts(
&lb_pair_state,
program.async_rpc(),
program.rpc(),
ActionType::Liquidity,
)
.await?
Expand Down Expand Up @@ -336,7 +339,7 @@ pub async fn execute_seed_liquidity_single_bin_by_operator<
instructions.push(deposit_ix);

let mut builder = program.request();
builder = builder.signer(&position_base_kp);
builder = builder.signer(position_base_kp.clone());
builder = instructions
.into_iter()
.fold(builder, |builder, ix| builder.instruction(ix));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ pub async fn execute_initialize_bin_array_with_price_range<
upper_price,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();
let lb_pair_state = rpc_client
.get_account_and_deserialize(&lb_pair, |account| {
Ok(LbPairAccount::deserialize(&account.data)?.0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub async fn execute_initialize_customizable_permissionless_lb_pair<
creator_pool_on_off_control,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();
let mut accounts = rpc_client
.get_multiple_accounts(&[token_mint_x, token_mint_y])
.await?;
Expand Down Expand Up @@ -87,7 +87,7 @@ pub async fn execute_initialize_customizable_permissionless_lb_pair<

let (lb_pair, _bump) = derive_customizable_permissionless_lb_pair(token_mint_x, token_mint_y);

if program.rpc().get_account_data(&lb_pair).is_ok() {
if program.rpc().get_account_data(&lb_pair).await.is_ok() {
return Ok(lb_pair);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ pub async fn execute_initialize_customizable_permissionless_lb_pair2<
creator_pool_on_off_control,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();
let mut accounts = rpc_client
.get_multiple_accounts(&[token_mint_x, token_mint_y])
.await?;
Expand Down Expand Up @@ -87,7 +87,7 @@ pub async fn execute_initialize_customizable_permissionless_lb_pair2<

let (lb_pair, _bump) = derive_customizable_permissionless_lb_pair(token_mint_x, token_mint_y);

if program.rpc().get_account_data(&lb_pair).is_ok() {
if program.rpc().get_account_data(&lb_pair).await.is_ok() {
return Ok(lb_pair);
}

Expand Down
4 changes: 2 additions & 2 deletions cli/src/instructions/initialize_lb_pair.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub async fn execute_initialize_lb_pair<C: Deref<Target = impl Signer> + Clone>(
initial_price,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();

let mut accounts = rpc_client
.get_multiple_accounts(&[token_mint_x, token_mint_y])
Expand Down Expand Up @@ -63,7 +63,7 @@ pub async fn execute_initialize_lb_pair<C: Deref<Target = impl Signer> + Clone>(
preset_parameter_state.base_factor,
);

if program.rpc().get_account_data(&lb_pair).is_ok() {
if program.rpc().get_account_data(&lb_pair).await.is_ok() {
return Ok(lb_pair);
}

Expand Down
4 changes: 2 additions & 2 deletions cli/src/instructions/initialize_lb_pair2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub async fn execute_initialize_lb_pair2<C: Deref<Target = impl Signer> + Clone>
initial_price,
} = params;

let rpc_client = program.async_rpc();
let rpc_client = program.rpc();

let mut accounts = rpc_client
.get_multiple_accounts(&[token_mint_x, token_mint_y])
Expand Down Expand Up @@ -59,7 +59,7 @@ pub async fn execute_initialize_lb_pair2<C: Deref<Target = impl Signer> + Clone>
let (lb_pair, _bump) =
derive_lb_pair_with_preset_parameter_key(preset_parameter, token_mint_x, token_mint_y);

if program.rpc().get_account_data(&lb_pair).is_ok() {
if program.rpc().get_account_data(&lb_pair).await.is_ok() {
return Ok(lb_pair);
}

Expand Down
6 changes: 4 additions & 2 deletions cli/src/instructions/initialize_position.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::sync::Arc;

use crate::*;

#[derive(Debug, Parser)]
Expand All @@ -22,7 +24,7 @@ pub async fn execute_initialize_position<C: Deref<Target = impl Signer> + Clone>
width,
} = params;

let position_keypair = Keypair::new();
let position_keypair = Arc::new(Keypair::new());

let (event_authority, _bump) = derive_event_authority_pda();

Expand Down Expand Up @@ -53,7 +55,7 @@ pub async fn execute_initialize_position<C: Deref<Target = impl Signer> + Clone>
let request_builder = program.request();
let signature = request_builder
.instruction(init_position_ix)
.signer(&position_keypair)
.signer(position_keypair.clone())
.send_with_spinner_and_config(transaction_config)
.await;

Expand Down
Loading