Skip to content

Commit 80233c0

Browse files
committed
anchor v0.32.1 + solana-program 2.2.1 update
1 parent d594180 commit 80233c0

File tree

29 files changed

+2572
-1573
lines changed

29 files changed

+2572
-1573
lines changed

Cargo.lock

Lines changed: 2445 additions & 1401 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

programs/drift/Cargo.toml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,24 +18,25 @@ default=["mainnet-beta", "no-entrypoint"]
1818
drift-rs=[]
1919

2020
[dependencies]
21-
anchor-lang = "0.29.0"
22-
solana-program = "1.16"
23-
anchor-spl = { version = "0.29.0", features = [] }
21+
anchor-lang = "0.32.1"
22+
anchor-spl = { version = "0.32.1", features = [] }
23+
# pin to highest version anchor crate allows
24+
solana-program = "=2.2.1"
2425
pyth-client = "0.2.2"
25-
pyth-lazer-solana-contract = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb", features = ["no-entrypoint"]}
26-
pythnet-sdk = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb"}
27-
pyth-solana-receiver-sdk = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb"}
26+
pyth-lazer-solana-contract = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master", features = ["no-entrypoint"]}
27+
pythnet-sdk = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master"}
28+
pyth-solana-receiver-sdk = { git = "https://github.com/jordy25519/pyth-crosschain", branch = "master"}
2829
bytemuck = { version = "1.4.0" }
2930
borsh = "0.10.3"
3031
hex = "0.4.3"
31-
num-traits = "0.2"
3232
uint = { version = "0.9.1", default-features = false }
3333
num-integer = "0.1.44"
34+
num-traits = "0.2"
3435
arrayref = "0.3.6"
3536
base64 = "0.13.0"
36-
serum_dex = { git = "https://github.com/project-serum/serum-dex", rev = "85b4f14", version = "0.5.6", features = ["no-entrypoint"] }
37+
serum_dex = { git = "https://github.com/jordy25519/serum-dex", branch = "master", features = ["no-entrypoint"] }
3738
enumflags2 = "0.6.4"
38-
phoenix-v1 = { git = "https://github.com/drift-labs/phoenix-v1", rev = "7703c5", version = "0.2.4", features = ["no-entrypoint"] }
39+
phoenix-v1 = { git = "https://github.com/jordy25519/phoenix-v1", branch = "master", features = ["no-entrypoint"] }
3940
solana-security-txt = "1.1.0"
4041
static_assertions = "1.1.0"
4142
drift-macros = { git = "https://github.com/drift-labs/drift-macros.git", rev = "c57d87" }

programs/drift/src/instructions/if_staker.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -504,9 +504,9 @@ pub fn handle_begin_insurance_fund_swap<'c: 'info, 'info>(
504504
found_end = true;
505505

506506
// must be the SwapEnd instruction
507-
let discriminator = crate::instruction::EndInsuranceFundSwap::discriminator();
507+
let discriminator = crate::instruction::EndInsuranceFundSwap::DISCRIMINATOR;
508508
validate!(
509-
ix.data[0..8] == discriminator,
509+
&ix.data[0..8] == discriminator,
510510
ErrorCode::InvalidSwap,
511511
"last drift ix must be end of swap"
512512
)?;

programs/drift/src/instructions/keeper.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,8 +1032,7 @@ pub fn place_signed_msg_taker_order<'c: 'info, 'info>(
10321032
&mut builder_order,
10331033
)?;
10341034

1035-
let order_params_hash =
1036-
base64::encode(solana_program::hash::hash(&signature.try_to_vec().unwrap()).as_ref());
1035+
let order_params_hash = base64::encode(solana_program::hash::hash(signature.as_ref()).as_ref());
10371036

10381037
emit!(SignedMsgOrderRecord {
10391038
user: taker_key,
@@ -1653,9 +1652,9 @@ pub fn handle_liquidate_spot_with_swap_begin<'c: 'info, 'info>(
16531652
found_end = true;
16541653

16551654
// must be the SwapEnd instruction
1656-
let discriminator = crate::instruction::LiquidateSpotWithSwapEnd::discriminator();
1655+
let discriminator = crate::instruction::LiquidateSpotWithSwapEnd::DISCRIMINATOR;
16571656
validate!(
1658-
ix.data[0..8] == discriminator,
1657+
&ix.data[0..8] == discriminator,
16591658
ErrorCode::InvalidLiquidateSpotWithSwap,
16601659
"last drift ix must be end of swap"
16611660
)?;

programs/drift/src/instructions/lp_admin.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -693,9 +693,9 @@ pub fn handle_begin_lp_swap<'c: 'info, 'info>(
693693
found_end = true;
694694

695695
// must be the SwapEnd instruction
696-
let discriminator = crate::instruction::EndLpSwap::discriminator();
696+
let discriminator = crate::instruction::EndLpSwap::DISCRIMINATOR;
697697
validate!(
698-
ix.data[0..8] == discriminator,
698+
&ix.data[0..8] == discriminator,
699699
ErrorCode::InvalidSwap,
700700
"last drift ix must be end of swap"
701701
)?;

programs/drift/src/instructions/optional_accounts.rs

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,8 @@ pub fn get_referrer_and_referrer_stats<'a>(
134134
return Ok((None, None));
135135
}
136136

137-
let user_discriminator: [u8; 8] = User::discriminator();
138-
let account_discriminator = array_ref![data, 0, 8];
139-
if account_discriminator != &user_discriminator {
137+
let account_discriminator = &data[..8];
138+
if account_discriminator != User::DISCRIMINATOR {
140139
return Ok((None, None));
141140
}
142141

@@ -165,9 +164,8 @@ pub fn get_referrer_and_referrer_stats<'a>(
165164
return Ok((None, None));
166165
}
167166

168-
let user_stats_discriminator: [u8; 8] = UserStats::discriminator();
169-
let account_discriminator = array_ref![data, 0, 8];
170-
if account_discriminator != &user_stats_discriminator {
167+
let account_discriminator = &data[..8];
168+
if account_discriminator != UserStats::DISCRIMINATOR {
171169
return Ok((None, None));
172170
}
173171

@@ -262,9 +260,8 @@ pub fn get_high_leverage_mode_config<'a>(
262260
return Ok(None);
263261
}
264262

265-
let high_leverage_mode_config_discriminator: [u8; 8] = HighLeverageModeConfig::discriminator();
266-
let account_discriminator = array_ref![data, 0, 8];
267-
if account_discriminator != &high_leverage_mode_config_discriminator {
263+
let account_discriminator = &data[..8];
264+
if account_discriminator != HighLeverageModeConfig::DISCRIMINATOR {
268265
return Ok(None);
269266
}
270267

@@ -293,10 +290,9 @@ pub fn get_revenue_share_escrow_account<'a>(
293290
return Ok(None);
294291
}
295292

296-
let discriminator: [u8; 8] = RevenueShareEscrow::discriminator();
297293
let borrowed_data = account_info.data.borrow();
298294
let account_discriminator = array_ref![&borrowed_data, 0, 8];
299-
if account_discriminator != &discriminator {
295+
if account_discriminator != RevenueShareEscrow::DISCRIMINATOR {
300296
return Ok(None);
301297
}
302298

programs/drift/src/instructions/user.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3606,9 +3606,9 @@ pub fn handle_begin_swap<'c: 'info, 'info>(
36063606
found_end = true;
36073607

36083608
// must be the SwapEnd instruction
3609-
let discriminator = crate::instruction::EndSwap::discriminator();
3609+
let discriminator = crate::instruction::EndSwap::DISCRIMINATOR;
36103610
validate!(
3611-
ix.data[0..8] == discriminator,
3611+
&ix.data[0..8] == discriminator,
36123612
ErrorCode::InvalidSwap,
36133613
"last drift ix must be end of swap"
36143614
)?;

programs/drift/src/macros.rs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -89,32 +89,16 @@ macro_rules! safe_decrement {
8989
}};
9090
}
9191

92-
/// Calculate the sha256 digest of anchor encoded `struct`
93-
#[macro_export]
94-
macro_rules! digest_struct {
95-
($struct:expr) => {
96-
solana_program::hash::hash(&$struct.try_to_vec().unwrap()).to_bytes()
97-
};
98-
}
99-
100-
/// Calculate the hexified sha256 digest of anchor encoded `struct`
101-
#[macro_export]
102-
macro_rules! digest_struct_hex {
103-
($struct:expr) => {{
104-
hex::encode(digest_struct!($struct)).into_bytes()
105-
}};
106-
}
107-
10892
/// same as `solana_program::msg!` but it can compile away for off-chain use
10993
#[macro_export]
11094
macro_rules! msg {
11195
($msg:expr) => {
11296
#[cfg(not(feature = "drift-rs"))]
113-
solana_program::msg!($msg)
97+
::solana_program::msg!($msg)
11498
};
11599
($($arg:tt)*) => {
116100
#[cfg(not(feature = "drift-rs"))]
117-
(solana_program::msg!(&format!($($arg)*)));
101+
(::solana_program::msg!(&format!($($arg)*)));
118102
}
119103
}
120104

programs/drift/src/math/liquidation/tests.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,14 +574,13 @@ mod calculate_cumulative_deposit_interest_delta_to_resolve_bankruptcy {
574574
}
575575

576576
mod validate_transfer_satisfies_limit_price {
577-
use crate::math::constants::{PRICE_PRECISION_U64, QUOTE_PRECISION};
577+
use crate::math::constants::{LAMPORTS_PER_SOL_U64, PRICE_PRECISION_U64, QUOTE_PRECISION};
578578
use crate::math::liquidation::validate_transfer_satisfies_limit_price;
579-
use anchor_lang::solana_program::native_token::LAMPORTS_PER_SOL;
580579

581580
#[test]
582581
fn sol_asset_usdc_liability() {
583582
let limit_price = PRICE_PRECISION_U64 / 100; // 1 SOL / $100 USD
584-
let asset = LAMPORTS_PER_SOL as u128;
583+
let asset = LAMPORTS_PER_SOL_U64 as u128;
585584
let asset_decimals = 9_u32;
586585
let liability = 100 * QUOTE_PRECISION;
587586
let liability_decimals = 6_u32;

programs/drift/src/math/orders/tests.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,6 @@ mod get_max_fill_amounts {
462462
use crate::state::user::{Order, SpotPosition, User};
463463
use crate::test_utils::get_orders;
464464
use crate::LAMPORTS_PER_SOL_U64;
465-
use anchor_spl::token::spl_token::solana_program::native_token::LAMPORTS_PER_SOL;
466465

467466
#[test]
468467
fn fully_collateralized_selling_base() {
@@ -493,7 +492,7 @@ mod get_max_fill_amounts {
493492
spot_positions,
494493
orders: get_orders(Order {
495494
direction: PositionDirection::Short,
496-
base_asset_amount: 100 * LAMPORTS_PER_SOL,
495+
base_asset_amount: 100 * LAMPORTS_PER_SOL_U64,
497496
..Order::default()
498497
}),
499498
..User::default()
@@ -531,7 +530,7 @@ mod get_max_fill_amounts {
531530
spot_positions,
532531
orders: get_orders(Order {
533532
direction: PositionDirection::Short,
534-
base_asset_amount: 100 * LAMPORTS_PER_SOL,
533+
base_asset_amount: 100 * LAMPORTS_PER_SOL_U64,
535534
..Order::default()
536535
}),
537536
..User::default()
@@ -572,7 +571,7 @@ mod get_max_fill_amounts {
572571
spot_positions,
573572
orders: get_orders(Order {
574573
direction: PositionDirection::Short,
575-
base_asset_amount: 100 * LAMPORTS_PER_SOL,
574+
base_asset_amount: 100 * LAMPORTS_PER_SOL_U64,
576575
..Order::default()
577576
}),
578577
..User::default()
@@ -614,7 +613,7 @@ mod get_max_fill_amounts {
614613
spot_positions,
615614
orders: get_orders(Order {
616615
direction: PositionDirection::Long,
617-
base_asset_amount: 100 * LAMPORTS_PER_SOL,
616+
base_asset_amount: 100 * LAMPORTS_PER_SOL_U64,
618617
..Order::default()
619618
}),
620619
..User::default()
@@ -652,7 +651,7 @@ mod get_max_fill_amounts {
652651
spot_positions,
653652
orders: get_orders(Order {
654653
direction: PositionDirection::Long,
655-
base_asset_amount: 100 * LAMPORTS_PER_SOL,
654+
base_asset_amount: 100 * LAMPORTS_PER_SOL_U64,
656655
..Order::default()
657656
}),
658657
..User::default()
@@ -694,7 +693,7 @@ mod get_max_fill_amounts {
694693
spot_positions,
695694
orders: get_orders(Order {
696695
direction: PositionDirection::Long,
697-
base_asset_amount: 100 * LAMPORTS_PER_SOL,
696+
base_asset_amount: 100 * LAMPORTS_PER_SOL_U64,
698697
..Order::default()
699698
}),
700699
..User::default()

0 commit comments

Comments
 (0)