Skip to content

Commit

Permalink
fix: resync program interface and cli
Browse files Browse the repository at this point in the history
  • Loading branch information
codewithgun committed Jan 7, 2025
1 parent 0be4b86 commit 983270b
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 58 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified artifacts/lb_clmm.so
Binary file not shown.
12 changes: 2 additions & 10 deletions cli/src/instructions/migrate_position_v3.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ pub async fn execute_migrate_position_v3<C: Deref<Target = impl Signer> + Clone>
})
.await?;

let lower_bin_array_idx = BinArray::bin_id_to_bin_array_index(position_state.lower_bin_id)?;
let (lower_bin_array_key, _bump) =
derive_bin_array_pda(position_state.lb_pair, lower_bin_array_idx.into());
let (upper_bin_array_key, _bump) =
derive_bin_array_pda(position_state.lb_pair, (lower_bin_array_idx + 1).into());

let position_v3_keypair = Keypair::new();
let (event_authority, _bump) = derive_event_authority_pda();

Expand All @@ -34,13 +28,11 @@ pub async fn execute_migrate_position_v3<C: Deref<Target = impl Signer> + Clone>
lb_pair: position_state.lb_pair,
position_v2: position,
position_v3: position_v3_keypair.pubkey(),
owner: program.payer(),
system_program: solana_sdk::system_program::ID,
program: dlmm_interface::ID,
bin_array_lower: lower_bin_array_key,
bin_array_upper: upper_bin_array_key,
rent_receiver: position_state.owner,
event_authority,
sender: program.payer(),
rent_receiver: position_state.owner,
}
.into();

Expand Down
64 changes: 19 additions & 45 deletions dlmm_interface/src/instructions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11421,15 +11421,13 @@ pub fn migrate_position_from_v1_verify_account_privileges<'me, 'info>(
migrate_position_from_v1_verify_signer_privileges(accounts)?;
Ok(())
}
pub const MIGRATE_POSITION_FROM_V2_IX_ACCOUNTS_LEN: usize = 10;
pub const MIGRATE_POSITION_FROM_V2_IX_ACCOUNTS_LEN: usize = 8;
#[derive(Copy, Clone, Debug)]
pub struct MigratePositionFromV2Accounts<'me, 'info> {
pub position_v3: &'me AccountInfo<'info>,
pub position_v2: &'me AccountInfo<'info>,
pub lb_pair: &'me AccountInfo<'info>,
pub bin_array_lower: &'me AccountInfo<'info>,
pub bin_array_upper: &'me AccountInfo<'info>,
pub owner: &'me AccountInfo<'info>,
pub sender: &'me AccountInfo<'info>,
pub system_program: &'me AccountInfo<'info>,
pub rent_receiver: &'me AccountInfo<'info>,
pub event_authority: &'me AccountInfo<'info>,
Expand All @@ -11440,9 +11438,7 @@ pub struct MigratePositionFromV2Keys {
pub position_v3: Pubkey,
pub position_v2: Pubkey,
pub lb_pair: Pubkey,
pub bin_array_lower: Pubkey,
pub bin_array_upper: Pubkey,
pub owner: Pubkey,
pub sender: Pubkey,
pub system_program: Pubkey,
pub rent_receiver: Pubkey,
pub event_authority: Pubkey,
Expand All @@ -11454,9 +11450,7 @@ impl From<MigratePositionFromV2Accounts<'_, '_>> for MigratePositionFromV2Keys {
position_v3: *accounts.position_v3.key,
position_v2: *accounts.position_v2.key,
lb_pair: *accounts.lb_pair.key,
bin_array_lower: *accounts.bin_array_lower.key,
bin_array_upper: *accounts.bin_array_upper.key,
owner: *accounts.owner.key,
sender: *accounts.sender.key,
system_program: *accounts.system_program.key,
rent_receiver: *accounts.rent_receiver.key,
event_authority: *accounts.event_authority.key,
Expand Down Expand Up @@ -11484,17 +11478,7 @@ for [AccountMeta; MIGRATE_POSITION_FROM_V2_IX_ACCOUNTS_LEN] {
is_writable: false,
},
AccountMeta {
pubkey: keys.bin_array_lower,
is_signer: false,
is_writable: true,
},
AccountMeta {
pubkey: keys.bin_array_upper,
is_signer: false,
is_writable: true,
},
AccountMeta {
pubkey: keys.owner,
pubkey: keys.sender,
is_signer: true,
is_writable: true,
},
Expand Down Expand Up @@ -11528,13 +11512,11 @@ for MigratePositionFromV2Keys {
position_v3: pubkeys[0],
position_v2: pubkeys[1],
lb_pair: pubkeys[2],
bin_array_lower: pubkeys[3],
bin_array_upper: pubkeys[4],
owner: pubkeys[5],
system_program: pubkeys[6],
rent_receiver: pubkeys[7],
event_authority: pubkeys[8],
program: pubkeys[9],
sender: pubkeys[3],
system_program: pubkeys[4],
rent_receiver: pubkeys[5],
event_authority: pubkeys[6],
program: pubkeys[7],
}
}
}
Expand All @@ -11545,9 +11527,7 @@ for [AccountInfo<'info>; MIGRATE_POSITION_FROM_V2_IX_ACCOUNTS_LEN] {
accounts.position_v3.clone(),
accounts.position_v2.clone(),
accounts.lb_pair.clone(),
accounts.bin_array_lower.clone(),
accounts.bin_array_upper.clone(),
accounts.owner.clone(),
accounts.sender.clone(),
accounts.system_program.clone(),
accounts.rent_receiver.clone(),
accounts.event_authority.clone(),
Expand All @@ -11567,13 +11547,11 @@ for MigratePositionFromV2Accounts<'me, 'info> {
position_v3: &arr[0],
position_v2: &arr[1],
lb_pair: &arr[2],
bin_array_lower: &arr[3],
bin_array_upper: &arr[4],
owner: &arr[5],
system_program: &arr[6],
rent_receiver: &arr[7],
event_authority: &arr[8],
program: &arr[9],
sender: &arr[3],
system_program: &arr[4],
rent_receiver: &arr[5],
event_authority: &arr[6],
program: &arr[7],
}
}
}
Expand Down Expand Up @@ -11668,9 +11646,7 @@ pub fn migrate_position_from_v2_verify_account_keys(
(*accounts.position_v3.key, keys.position_v3),
(*accounts.position_v2.key, keys.position_v2),
(*accounts.lb_pair.key, keys.lb_pair),
(*accounts.bin_array_lower.key, keys.bin_array_lower),
(*accounts.bin_array_upper.key, keys.bin_array_upper),
(*accounts.owner.key, keys.owner),
(*accounts.sender.key, keys.sender),
(*accounts.system_program.key, keys.system_program),
(*accounts.rent_receiver.key, keys.rent_receiver),
(*accounts.event_authority.key, keys.event_authority),
Expand All @@ -11688,9 +11664,7 @@ pub fn migrate_position_from_v2_verify_writable_privileges<'me, 'info>(
for should_be_writable in [
accounts.position_v3,
accounts.position_v2,
accounts.bin_array_lower,
accounts.bin_array_upper,
accounts.owner,
accounts.sender,
accounts.rent_receiver,
] {
if !should_be_writable.is_writable {
Expand All @@ -11702,7 +11676,7 @@ pub fn migrate_position_from_v2_verify_writable_privileges<'me, 'info>(
pub fn migrate_position_from_v2_verify_signer_privileges<'me, 'info>(
accounts: MigratePositionFromV2Accounts<'me, 'info>,
) -> Result<(), (&'me AccountInfo<'info>, ProgramError)> {
for should_be_signer in [accounts.position_v3, accounts.owner] {
for should_be_signer in [accounts.position_v3, accounts.sender] {
if !should_be_signer.is_signer {
return Err((should_be_signer, ProgramError::MissingRequiredSignature));
}
Expand Down
2 changes: 0 additions & 2 deletions dlmm_interface/src/typedefs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ pub struct InitPresetParametersIx {
pub reduction_factor: u16,
pub variable_fee_control: u32,
pub max_volatility_accumulator: u32,
pub min_bin_id: i32,
pub max_bin_id: i32,
pub protocol_share: u16,
}
#[derive(Clone, Debug, BorshDeserialize, BorshSerialize, PartialEq)]
Expand Down

0 comments on commit 983270b

Please sign in to comment.