Skip to content

Commit 415f247

Browse files
authored
Revert recent builder codes chain and merge (#1848)
* Revert recent builder codes chain and merge * update driftclient * disable extra instructions, fix builder code feature flag selection
1 parent 5db315b commit 415f247

Some content is hidden

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

41 files changed

+783
-19597
lines changed

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 = { version = "0.29.0", features = [] }
23+
anchor-spl = "0.29.0"
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: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,7 +1203,7 @@ fn amm_perp_ref_offset() {
12031203
max_ref_offset,
12041204
)
12051205
.unwrap();
1206-
assert_eq!(res, 45000);
1206+
assert_eq!(res, (perp_market.amm.max_spread / 2) as i32);
12071207
assert_eq!(perp_market.amm.reference_price_offset, 18000); // not updated vs market account
12081208

12091209
let now = 1741207620 + 1;
@@ -1281,15 +1281,21 @@ fn amm_perp_ref_offset() {
12811281
// Uses the original oracle if the slot is old, ignoring MM oracle
12821282
perp_market.amm.mm_oracle_price = mm_oracle_price_data.get_price() * 995 / 1000;
12831283
perp_market.amm.mm_oracle_slot = clock_slot - 100;
1284-
let mm_oracle_price = perp_market
1284+
let mut mm_oracle_price = perp_market
12851285
.get_mm_oracle_price_data(
12861286
oracle_price_data,
12871287
clock_slot,
12881288
&state.oracle_guard_rails.validity,
12891289
)
12901290
.unwrap();
12911291

1292-
let _ = _update_amm(&mut perp_market, &mm_oracle_price, &state, now, clock_slot);
1292+
let _ = _update_amm(
1293+
&mut perp_market,
1294+
&mut mm_oracle_price,
1295+
&state,
1296+
now,
1297+
clock_slot,
1298+
);
12931299
let reserve_price_mm_offset_3 = perp_market.amm.reserve_price().unwrap();
12941300
let (b3, a3) = perp_market
12951301
.amm
@@ -1724,7 +1730,7 @@ fn amm_split_large_k_with_rebase() {
17241730
delay: 14,
17251731
has_sufficient_number_of_data_points: true,
17261732
};
1727-
let mm_oracle_price_data = perp_market
1733+
let mut mm_oracle_price = perp_market
17281734
.get_mm_oracle_price_data(
17291735
oracle_price_data,
17301736
clock_slot,
@@ -1734,7 +1740,7 @@ fn amm_split_large_k_with_rebase() {
17341740

17351741
let cost = _update_amm(
17361742
&mut perp_market,
1737-
&mm_oracle_price_data,
1743+
&mut mm_oracle_price,
17381744
&state,
17391745
now,
17401746
clock_slot,

programs/drift/src/controller/spot_balance.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -250,12 +250,10 @@ pub fn update_spot_balances(
250250
}
251251

252252
if token_amount > 0 {
253-
msg!("token amount to transfer: {}", token_amount);
254253
spot_balance.update_balance_type(*update_direction)?;
255254
let round_up = update_direction == &SpotBalanceType::Borrow;
256255
let balance_delta =
257256
get_spot_balance(token_amount, spot_market, update_direction, round_up)?;
258-
msg!("balance delta {}", balance_delta);
259257
spot_balance.increase_balance(balance_delta)?;
260258
increase_spot_balance(balance_delta, spot_market, update_direction)?;
261259
}

programs/drift/src/controller/token.rs

Lines changed: 1 addition & 53 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, Burn, CloseAccount, Mint, MintTo, TokenAccount, TokenInterface, Transfer, TransferChecked,
12+
self, CloseAccount, Mint, TokenAccount, TokenInterface, Transfer, TransferChecked,
1313
};
1414
use std::iter::Peekable;
1515
use std::slice::Iter;
@@ -137,58 +137,6 @@ pub fn close_vault<'info>(
137137
token_interface::close_account(cpi_context)
138138
}
139139

140-
pub fn mint_tokens<'info>(
141-
token_program: &Interface<'info, TokenInterface>,
142-
destination: &InterfaceAccount<'info, TokenAccount>,
143-
authority: &AccountInfo<'info>,
144-
nonce: u8,
145-
amount: u64,
146-
mint: &InterfaceAccount<'info, Mint>,
147-
) -> Result<()> {
148-
let signature_seeds = get_signer_seeds(&nonce);
149-
let signers = &[&signature_seeds[..]];
150-
151-
let mint_account_info = mint.to_account_info();
152-
153-
validate_mint_fee(&mint_account_info)?;
154-
155-
let cpi_accounts = MintTo {
156-
mint: mint_account_info,
157-
to: destination.to_account_info(),
158-
authority: authority.to_account_info(),
159-
};
160-
161-
let cpi_program = token_program.to_account_info();
162-
let cpi_context = CpiContext::new_with_signer(cpi_program, cpi_accounts, signers);
163-
token_interface::mint_to(cpi_context, amount)
164-
}
165-
166-
pub fn burn_tokens<'info>(
167-
token_program: &Interface<'info, TokenInterface>,
168-
destination: &InterfaceAccount<'info, TokenAccount>,
169-
authority: &AccountInfo<'info>,
170-
nonce: u8,
171-
amount: u64,
172-
mint: &InterfaceAccount<'info, Mint>,
173-
) -> Result<()> {
174-
let signature_seeds = get_signer_seeds(&nonce);
175-
let signers = &[&signature_seeds[..]];
176-
177-
let mint_account_info = mint.to_account_info();
178-
179-
validate_mint_fee(&mint_account_info)?;
180-
181-
let cpi_accounts = Burn {
182-
mint: mint_account_info,
183-
from: destination.to_account_info(),
184-
authority: authority.to_account_info(),
185-
};
186-
187-
let cpi_program = token_program.to_account_info();
188-
let cpi_context = CpiContext::new_with_signer(cpi_program, cpi_accounts, signers);
189-
token_interface::burn(cpi_context, amount)
190-
}
191-
192140
pub fn validate_mint_fee(account_info: &AccountInfo) -> Result<()> {
193141
let mint_data = account_info.try_borrow_data()?;
194142
let mint_with_extension = StateWithExtensions::<MintInner>::unpack(&mint_data)?;

programs/drift/src/error.rs

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

45
#[error_code]
@@ -656,40 +657,6 @@ pub enum ErrorCode {
656657
UnableToLoadRevenueShareAccount,
657658
#[msg("RevenueShare order not found")]
658659
RevenueShareOrderNotFound,
659-
#[msg("Invalid Constituent")]
660-
InvalidConstituent,
661-
#[msg("Invalid Amm Constituent Mapping argument")]
662-
InvalidAmmConstituentMappingArgument,
663-
#[msg("Invalid update constituent update target weights argument")]
664-
InvalidUpdateConstituentTargetBaseArgument,
665-
#[msg("Constituent not found")]
666-
ConstituentNotFound,
667-
#[msg("Constituent could not load")]
668-
ConstituentCouldNotLoad,
669-
#[msg("Constituent wrong mutability")]
670-
ConstituentWrongMutability,
671-
#[msg("Wrong number of constituents passed to instruction")]
672-
WrongNumberOfConstituents,
673-
#[msg("Oracle too stale for LP AUM update")]
674-
OracleTooStaleForLPAUMUpdate,
675-
#[msg("Insufficient constituent token balance")]
676-
InsufficientConstituentTokenBalance,
677-
#[msg("Amm Cache data too stale")]
678-
AMMCacheStale,
679-
#[msg("LP Pool AUM not updated recently")]
680-
LpPoolAumDelayed,
681-
#[msg("Constituent oracle is stale")]
682-
ConstituentOracleStale,
683-
#[msg("LP Invariant failed")]
684-
LpInvariantFailed,
685-
#[msg("Invalid constituent derivative weights")]
686-
InvalidConstituentDerivativeWeights,
687-
#[msg("Unauthorized dlp authority")]
688-
UnauthorizedDlpAuthority,
689-
#[msg("Max DLP AUM Breached")]
690-
MaxDlpAumBreached,
691-
#[msg("Settle Lp Pool Disabled")]
692-
SettleLpPoolDisabled,
693660
}
694661

695662
#[macro_export]

programs/drift/src/ids.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
1-
use anchor_lang::prelude::Pubkey;
2-
use solana_program::pubkey;
3-
41
pub mod pyth_program {
52
use solana_program::declare_id;
63
#[cfg(feature = "mainnet-beta")]
@@ -91,11 +88,6 @@ pub mod lighthouse {
9188
declare_id!("L2TExMFKdjpN9kozasaurPirfHy9P8sbXoAN1qA3S95");
9289
}
9390

94-
pub mod usdc_mint {
95-
use solana_program::declare_id;
96-
declare_id!("BJE5MMbqXjVwjAF7oxwPYXnTXDyspzZyt4vwenNw5ruG");
97-
}
98-
9991
pub mod mm_oracle_crank_wallet {
10092
use solana_program::declare_id;
10193
#[cfg(not(feature = "anchor-test"))]
@@ -115,11 +107,3 @@ pub mod amm_spread_adjust_wallet {
115107
#[cfg(feature = "anchor-test")]
116108
declare_id!("1ucYHAGrBbi1PaecC4Ptq5ocZLWGLBmbGWysoDGNB1N");
117109
}
118-
119-
#[cfg(not(feature = "mainnet-beta"))]
120-
pub const DLP_WHITELIST: [Pubkey; 2] = [
121-
pubkey!("4rmhwytmKH1XsgGAUyUUH7U64HS5FtT6gM8HGKAfwcFE"),
122-
pubkey!("1ucYHAGrBbi1PaecC4Ptq5ocZLWGLBmbGWysoDGNB1N"),
123-
];
124-
#[cfg(feature = "mainnet-beta")]
125-
pub const DLP_WHITELIST: [Pubkey; 1] = [pubkey!("1ucYHAGrBbi1PaecC4Ptq5ocZLWGLBmbGWysoDGNB1N")];

0 commit comments

Comments
 (0)