Skip to content

Commit e6e3999

Browse files
committed
Merge remote-tracking branch 'origin/dlp' into devnet
2 parents a1719bb + ecd8d3a commit e6e3999

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+21589
-524
lines changed

CHANGELOG.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7474

7575
### Breaking
7676

77-
## [2.135.0] - 2025-08-22
78-
79-
### Features
80-
81-
### Fixes
82-
83-
- program: trigger price use 5min mark price ([#1830](https://github.com/drift-labs/protocol-v2/pull/1830))
84-
85-
### Breaking
86-
8777
## [2.134.0] - 2025-08-13
8878

8979
### Features

programs/drift/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ drift-rs=[]
2020
[dependencies]
2121
anchor-lang = "0.29.0"
2222
solana-program = "1.16"
23-
anchor-spl = "0.29.0"
23+
anchor-spl = { version = "0.29.0", features = [] }
2424
pyth-client = "0.2.2"
2525
pyth-lazer-solana-contract = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb", features = ["no-entrypoint"]}
2626
pythnet-sdk = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "3e8a24ecd0bcf22b787313e2020f4186bb22c729"}

programs/drift/src/controller/position/tests.rs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,7 +1177,7 @@ fn amm_perp_ref_offset() {
11771177
max_ref_offset,
11781178
)
11791179
.unwrap();
1180-
assert_eq!(res, (perp_market.amm.max_spread / 2) as i32);
1180+
assert_eq!(res, 45000);
11811181
assert_eq!(perp_market.amm.reference_price_offset, 18000); // not updated vs market account
11821182

11831183
let now = 1741207620 + 1;
@@ -1256,21 +1256,15 @@ fn amm_perp_ref_offset() {
12561256
// Uses the original oracle if the slot is old, ignoring MM oracle
12571257
perp_market.amm.mm_oracle_price = mm_oracle_price_data.get_price() * 995 / 1000;
12581258
perp_market.amm.mm_oracle_slot = clock_slot - 100;
1259-
let mut mm_oracle_price = perp_market
1259+
let mm_oracle_price = perp_market
12601260
.get_mm_oracle_price_data(
12611261
oracle_price_data,
12621262
clock_slot,
12631263
&state.oracle_guard_rails.validity,
12641264
)
12651265
.unwrap();
12661266

1267-
let _ = _update_amm(
1268-
&mut perp_market,
1269-
&mut mm_oracle_price,
1270-
&state,
1271-
now,
1272-
clock_slot,
1273-
);
1267+
let _ = _update_amm(&mut perp_market, &mm_oracle_price, &state, now, clock_slot);
12741268
let reserve_price_mm_offset_3 = perp_market.amm.reserve_price().unwrap();
12751269
let (b3, a3) = perp_market
12761270
.amm

programs/drift/src/controller/token.rs

Lines changed: 76 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use anchor_spl::token_2022::spl_token_2022::extension::{
99
};
1010
use anchor_spl::token_2022::spl_token_2022::state::Mint as MintInner;
1111
use anchor_spl::token_interface::{
12-
self, CloseAccount, Mint, TokenAccount, TokenInterface, Transfer, TransferChecked,
12+
self, Burn, CloseAccount, Mint, MintTo, TokenAccount, TokenInterface, Transfer, TransferChecked,
1313
};
1414
use std::iter::Peekable;
1515
use std::slice::Iter;
@@ -25,7 +25,31 @@ pub fn send_from_program_vault<'info>(
2525
remaining_accounts: Option<&mut Peekable<Iter<'info, AccountInfo<'info>>>>,
2626
) -> Result<()> {
2727
let signature_seeds = get_signer_seeds(&nonce);
28-
let signers = &[&signature_seeds[..]];
28+
29+
send_from_program_vault_with_signature_seeds(
30+
token_program,
31+
from,
32+
to,
33+
authority,
34+
&signature_seeds,
35+
amount,
36+
mint,
37+
remaining_accounts,
38+
)
39+
}
40+
41+
#[inline]
42+
pub fn send_from_program_vault_with_signature_seeds<'info>(
43+
token_program: &Interface<'info, TokenInterface>,
44+
from: &InterfaceAccount<'info, TokenAccount>,
45+
to: &InterfaceAccount<'info, TokenAccount>,
46+
authority: &AccountInfo<'info>,
47+
signature_seeds: &[&[u8]],
48+
amount: u64,
49+
mint: &Option<InterfaceAccount<'info, Mint>>,
50+
remaining_accounts: Option<&mut Peekable<Iter<'info, AccountInfo<'info>>>>,
51+
) -> Result<()> {
52+
let signers = &[signature_seeds];
2953

3054
if let Some(mint) = mint {
3155
if let Some(remaining_accounts) = remaining_accounts {
@@ -137,6 +161,56 @@ pub fn close_vault<'info>(
137161
token_interface::close_account(cpi_context)
138162
}
139163

164+
pub fn mint_tokens<'info>(
165+
token_program: &Interface<'info, TokenInterface>,
166+
destination: &InterfaceAccount<'info, TokenAccount>,
167+
authority: &AccountInfo<'info>,
168+
signature_seeds: &[&[u8]],
169+
amount: u64,
170+
mint: &InterfaceAccount<'info, Mint>,
171+
) -> Result<()> {
172+
let signers = &[signature_seeds];
173+
174+
let mint_account_info = mint.to_account_info();
175+
176+
validate_mint_fee(&mint_account_info)?;
177+
178+
let cpi_accounts = MintTo {
179+
mint: mint_account_info,
180+
to: destination.to_account_info(),
181+
authority: authority.to_account_info(),
182+
};
183+
184+
let cpi_program = token_program.to_account_info();
185+
let cpi_context = CpiContext::new_with_signer(cpi_program, cpi_accounts, signers);
186+
token_interface::mint_to(cpi_context, amount)
187+
}
188+
189+
pub fn burn_tokens<'info>(
190+
token_program: &Interface<'info, TokenInterface>,
191+
destination: &InterfaceAccount<'info, TokenAccount>,
192+
authority: &AccountInfo<'info>,
193+
signature_seeds: &[&[u8]],
194+
amount: u64,
195+
mint: &InterfaceAccount<'info, Mint>,
196+
) -> Result<()> {
197+
let signers = &[signature_seeds];
198+
199+
let mint_account_info = mint.to_account_info();
200+
201+
validate_mint_fee(&mint_account_info)?;
202+
203+
let cpi_accounts = Burn {
204+
mint: mint_account_info,
205+
from: destination.to_account_info(),
206+
authority: authority.to_account_info(),
207+
};
208+
209+
let cpi_program = token_program.to_account_info();
210+
let cpi_context = CpiContext::new_with_signer(cpi_program, cpi_accounts, signers);
211+
token_interface::burn(cpi_context, amount)
212+
}
213+
140214
pub fn validate_mint_fee(account_info: &AccountInfo) -> Result<()> {
141215
let mint_data = account_info.try_borrow_data()?;
142216
let mint_with_extension = StateWithExtensions::<MintInner>::unpack(&mint_data)?;

programs/drift/src/error.rs

Lines changed: 42 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
use anchor_lang::prelude::*;
2-
32
pub type DriftResult<T = ()> = std::result::Result<T, ErrorCode>;
43

54
#[error_code]
@@ -655,6 +654,48 @@ pub enum ErrorCode {
655654
CannotRevokeBuilderWithOpenOrders,
656655
#[msg("Unable to load builder account")]
657656
UnableToLoadRevenueShareAccount,
657+
#[msg("Invalid Constituent")]
658+
InvalidConstituent,
659+
#[msg("Invalid Amm Constituent Mapping argument")]
660+
InvalidAmmConstituentMappingArgument,
661+
#[msg("Invalid update constituent update target weights argument")]
662+
InvalidUpdateConstituentTargetBaseArgument,
663+
#[msg("Constituent not found")]
664+
ConstituentNotFound,
665+
#[msg("Constituent could not load")]
666+
ConstituentCouldNotLoad,
667+
#[msg("Constituent wrong mutability")]
668+
ConstituentWrongMutability,
669+
#[msg("Wrong number of constituents passed to instruction")]
670+
WrongNumberOfConstituents,
671+
#[msg("Oracle too stale for LP AUM update")]
672+
OracleTooStaleForLPAUMUpdate,
673+
#[msg("Insufficient constituent token balance")]
674+
InsufficientConstituentTokenBalance,
675+
#[msg("Amm Cache data too stale")]
676+
AMMCacheStale,
677+
#[msg("LP Pool AUM not updated recently")]
678+
LpPoolAumDelayed,
679+
#[msg("Constituent oracle is stale")]
680+
ConstituentOracleStale,
681+
#[msg("LP Invariant failed")]
682+
LpInvariantFailed,
683+
#[msg("Invalid constituent derivative weights")]
684+
InvalidConstituentDerivativeWeights,
685+
#[msg("Unauthorized dlp authority")]
686+
UnauthorizedDlpAuthority,
687+
#[msg("Max DLP AUM Breached")]
688+
MaxDlpAumBreached,
689+
#[msg("Settle Lp Pool Disabled")]
690+
SettleLpPoolDisabled,
691+
#[msg("Mint/Redeem Lp Pool Disabled")]
692+
MintRedeemLpPoolDisabled,
693+
#[msg("Settlement amount exceeded")]
694+
LpPoolSettleInvariantBreached,
695+
#[msg("Invalid constituent operation")]
696+
InvalidConstituentOperation,
697+
#[msg("Unauthorized for operation")]
698+
Unauthorized,
658699
}
659700

660701
#[macro_export]

programs/drift/src/ids.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
use anchor_lang::prelude::Pubkey;
2+
use solana_program::pubkey;
3+
14
pub mod pyth_program {
25
use solana_program::declare_id;
36
#[cfg(feature = "mainnet-beta")]
@@ -107,3 +110,8 @@ pub mod amm_spread_adjust_wallet {
107110
#[cfg(feature = "anchor-test")]
108111
declare_id!("1ucYHAGrBbi1PaecC4Ptq5ocZLWGLBmbGWysoDGNB1N");
109112
}
113+
114+
pub mod lp_pool_swap_wallet {
115+
use solana_program::declare_id;
116+
declare_id!("25qbsE2oWri76c9a86ubn17NKKdo6Am4HXD2Jm8vT8K4");
117+
}

0 commit comments

Comments
 (0)