Skip to content
Open

DLP #1885

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
5cef2f8
Bigz/init lp pool (#1884)
moosecat2 Sep 16, 2025
03b22b8
add vamm cache percent scalar (default is 100)
moosecat2 Sep 17, 2025
eecbe20
Merge pull request #1888 from drift-labs/nour/vamm-cache-percent
moosecat2 Sep 17, 2025
dc43396
aum cant go below zero (#1890)
moosecat2 Sep 17, 2025
497638d
reassing dlp taker bot wallet
moosecat2 Sep 18, 2025
6976e55
add event subscriber changes for dlp events
moosecat2 Sep 18, 2025
9d7a2b6
give permission for dlp taker bot to deposit withdraw from program va…
moosecat2 Sep 19, 2025
a814f7b
fix max withdrawals bug
moosecat2 Sep 19, 2025
d1060ff
get max transfer bug fix
moosecat2 Sep 20, 2025
2db9320
merge master
moosecat2 Sep 20, 2025
010c210
Wphan/merge-master (#1915)
wphan Sep 25, 2025
8757c93
add new bulk instruction packaging
moosecat2 Sep 29, 2025
e3d08a0
logging changes
moosecat2 Sep 29, 2025
ecd8d3a
Wphan/master-dlp (#1918)
wphan Sep 29, 2025
53a5009
borrow lend accounting (#1905)
moosecat2 Sep 29, 2025
88d1dc8
remove duplicate admin client funcs
moosecat2 Sep 29, 2025
6faf6a2
update idl
wphan Sep 29, 2025
f1a23d8
bump constituent map max size
moosecat2 Sep 30, 2025
cec4e6d
make working devcontainer and dockerfile
wphan Sep 30, 2025
61a5657
bug fixes
moosecat2 Sep 30, 2025
bcb5ded
bug fixes
moosecat2 Sep 30, 2025
025eaf3
add dev container
moosecat2 Sep 30, 2025
55b530d
fix node version
wphan Sep 30, 2025
51e2e27
update dockerfile
moosecat2 Sep 30, 2025
dfec9a3
fixed idl
moosecat2 Sep 30, 2025
199f504
dockerfile and dev container working, and anchor build working
moosecat2 Sep 30, 2025
19efd62
add dev container.json and dockerfile
moosecat2 Sep 30, 2025
c768376
update dlp types to include lp pool key
moosecat2 Oct 1, 2025
340b6c9
stable target base liquidity fix + cleanup
moosecat2 Oct 1, 2025
631c962
relax transfer from program lp invariant for devnet
moosecat2 Oct 1, 2025
8f6f9bc
further restrict constituent max borrow
moosecat2 Oct 2, 2025
ede599b
give 1% flexilibity for race conditions on max transfer amount
moosecat2 Oct 2, 2025
60a9231
introduce max borrow buffer
moosecat2 Oct 2, 2025
72a5e42
include new amm inventory limit (#1932)
moosecat2 Oct 3, 2025
bc1ae68
refactor amm cache
moosecat2 Oct 3, 2025
6f881ba
change amm cache pda seed for devnet reset
moosecat2 Oct 3, 2025
8b73b66
update sdk types file to be up to parity
moosecat2 Oct 6, 2025
41fbaa3
merge master into dlp
moosecat2 Oct 6, 2025
69afe90
clean up and guard against negative amm_inventory_limit
moosecat2 Oct 7, 2025
0cd3560
Target delay increases fees (#1943)
moosecat2 Oct 8, 2025
84ce292
update idl
moosecat2 Oct 8, 2025
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
17 changes: 12 additions & 5 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,18 @@ ENV HOME="/root"
ENV PATH="/usr/local/cargo/bin:${PATH}"
ENV PATH="/root/.local/share/solana/install/active_release/bin:${PATH}"

RUN mkdir -p /workdir /tmp && \
apt-get update -qq && apt-get upgrade -qq && apt-get install -y --no-install-recommends \
build-essential git curl wget jq pkg-config python3-pip xz-utils ca-certificates \
libssl-dev libudev-dev bash && \
rm -rf /var/lib/apt/lists/*
RUN mkdir -p /workdir /tmp \
&& apt-get update -qq \
&& apt-get upgrade -qq \
&& apt-get install -y --no-install-recommends \
build-essential git curl wget jq pkg-config python3-pip xz-utils ca-certificates \
libssl-dev libudev-dev bash software-properties-common \
&& add-apt-repository 'deb http://deb.debian.org/debian bookworm main' \
&& apt-get update -qq \
&& apt-get install -y libc6 libc6-dev \
&& rm -rf /var/lib/apt/lists/*

RUN rustup component add rustfmt

RUN rustup install 1.78.0 \
&& rustup component add rustfmt clippy --toolchain 1.78.0
Expand Down
10 changes: 0 additions & 10 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Breaking

## [2.135.0] - 2025-08-22

### Features

### Fixes

- program: trigger price use 5min mark price ([#1830](https://github.com/drift-labs/protocol-v2/pull/1830))

### Breaking

## [2.134.0] - 2025-08-13

### Features
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,5 +94,6 @@
"chalk-template": "<1.1.1",
"supports-hyperlinks": "<4.1.1",
"has-ansi": "<6.0.1"
}
}
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
}
2 changes: 1 addition & 1 deletion programs/drift/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ drift-rs=[]
[dependencies]
anchor-lang = "0.29.0"
solana-program = "1.16"
anchor-spl = "0.29.0"
anchor-spl = { version = "0.29.0", features = [] }
pyth-client = "0.2.2"
pyth-lazer-solana-contract = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "d790d1cb4da873a949cf33ff70349b7614b232eb", features = ["no-entrypoint"]}
pythnet-sdk = { git = "https://github.com/drift-labs/pyth-crosschain", rev = "3e8a24ecd0bcf22b787313e2020f4186bb22c729"}
Expand Down
12 changes: 3 additions & 9 deletions programs/drift/src/controller/position/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ fn amm_perp_ref_offset() {
max_ref_offset,
)
.unwrap();
assert_eq!(res, (perp_market.amm.max_spread / 2) as i32);
assert_eq!(res, 45000);
assert_eq!(perp_market.amm.reference_price_offset, 18000); // not updated vs market account

let now = 1741207620 + 1;
Expand Down Expand Up @@ -1256,21 +1256,15 @@ fn amm_perp_ref_offset() {
// Uses the original oracle if the slot is old, ignoring MM oracle
perp_market.amm.mm_oracle_price = mm_oracle_price_data.get_price() * 995 / 1000;
perp_market.amm.mm_oracle_slot = clock_slot - 100;
let mut mm_oracle_price = perp_market
let mm_oracle_price = perp_market
.get_mm_oracle_price_data(
oracle_price_data,
clock_slot,
&state.oracle_guard_rails.validity,
)
.unwrap();

let _ = _update_amm(
&mut perp_market,
&mut mm_oracle_price,
&state,
now,
clock_slot,
);
let _ = _update_amm(&mut perp_market, &mm_oracle_price, &state, now, clock_slot);
let reserve_price_mm_offset_3 = perp_market.amm.reserve_price().unwrap();
let (b3, a3) = perp_market
.amm
Expand Down
78 changes: 76 additions & 2 deletions programs/drift/src/controller/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use anchor_spl::token_2022::spl_token_2022::extension::{
};
use anchor_spl::token_2022::spl_token_2022::state::Mint as MintInner;
use anchor_spl::token_interface::{
self, CloseAccount, Mint, TokenAccount, TokenInterface, Transfer, TransferChecked,
self, Burn, CloseAccount, Mint, MintTo, TokenAccount, TokenInterface, Transfer, TransferChecked,
};
use std::iter::Peekable;
use std::slice::Iter;
Expand All @@ -25,7 +25,31 @@ pub fn send_from_program_vault<'info>(
remaining_accounts: Option<&mut Peekable<Iter<'info, AccountInfo<'info>>>>,
) -> Result<()> {
let signature_seeds = get_signer_seeds(&nonce);
let signers = &[&signature_seeds[..]];

send_from_program_vault_with_signature_seeds(
token_program,
from,
to,
authority,
&signature_seeds,
amount,
mint,
remaining_accounts,
)
}

#[inline]
pub fn send_from_program_vault_with_signature_seeds<'info>(
token_program: &Interface<'info, TokenInterface>,
from: &InterfaceAccount<'info, TokenAccount>,
to: &InterfaceAccount<'info, TokenAccount>,
authority: &AccountInfo<'info>,
signature_seeds: &[&[u8]],
amount: u64,
mint: &Option<InterfaceAccount<'info, Mint>>,
remaining_accounts: Option<&mut Peekable<Iter<'info, AccountInfo<'info>>>>,
) -> Result<()> {
let signers = &[signature_seeds];

if let Some(mint) = mint {
if let Some(remaining_accounts) = remaining_accounts {
Expand Down Expand Up @@ -137,6 +161,56 @@ pub fn close_vault<'info>(
token_interface::close_account(cpi_context)
}

pub fn mint_tokens<'info>(
token_program: &Interface<'info, TokenInterface>,
destination: &InterfaceAccount<'info, TokenAccount>,
authority: &AccountInfo<'info>,
signature_seeds: &[&[u8]],
amount: u64,
mint: &InterfaceAccount<'info, Mint>,
) -> Result<()> {
let signers = &[signature_seeds];

let mint_account_info = mint.to_account_info();

validate_mint_fee(&mint_account_info)?;

let cpi_accounts = MintTo {
mint: mint_account_info,
to: destination.to_account_info(),
authority: authority.to_account_info(),
};

let cpi_program = token_program.to_account_info();
let cpi_context = CpiContext::new_with_signer(cpi_program, cpi_accounts, signers);
token_interface::mint_to(cpi_context, amount)
}

pub fn burn_tokens<'info>(
token_program: &Interface<'info, TokenInterface>,
destination: &InterfaceAccount<'info, TokenAccount>,
authority: &AccountInfo<'info>,
signature_seeds: &[&[u8]],
amount: u64,
mint: &InterfaceAccount<'info, Mint>,
) -> Result<()> {
let signers = &[signature_seeds];

let mint_account_info = mint.to_account_info();

validate_mint_fee(&mint_account_info)?;

let cpi_accounts = Burn {
mint: mint_account_info,
from: destination.to_account_info(),
authority: authority.to_account_info(),
};

let cpi_program = token_program.to_account_info();
let cpi_context = CpiContext::new_with_signer(cpi_program, cpi_accounts, signers);
token_interface::burn(cpi_context, amount)
}

pub fn validate_mint_fee(account_info: &AccountInfo) -> Result<()> {
let mint_data = account_info.try_borrow_data()?;
let mint_with_extension = StateWithExtensions::<MintInner>::unpack(&mint_data)?;
Expand Down
43 changes: 42 additions & 1 deletion programs/drift/src/error.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
use anchor_lang::prelude::*;

pub type DriftResult<T = ()> = std::result::Result<T, ErrorCode>;

#[error_code]
Expand Down Expand Up @@ -655,6 +654,48 @@ pub enum ErrorCode {
CannotRevokeBuilderWithOpenOrders,
#[msg("Unable to load builder account")]
UnableToLoadRevenueShareAccount,
#[msg("Invalid Constituent")]
InvalidConstituent,
#[msg("Invalid Amm Constituent Mapping argument")]
InvalidAmmConstituentMappingArgument,
#[msg("Invalid update constituent update target weights argument")]
InvalidUpdateConstituentTargetBaseArgument,
#[msg("Constituent not found")]
ConstituentNotFound,
#[msg("Constituent could not load")]
ConstituentCouldNotLoad,
#[msg("Constituent wrong mutability")]
ConstituentWrongMutability,
#[msg("Wrong number of constituents passed to instruction")]
WrongNumberOfConstituents,
#[msg("Oracle too stale for LP AUM update")]
OracleTooStaleForLPAUMUpdate,
#[msg("Insufficient constituent token balance")]
InsufficientConstituentTokenBalance,
#[msg("Amm Cache data too stale")]
AMMCacheStale,
#[msg("LP Pool AUM not updated recently")]
LpPoolAumDelayed,
#[msg("Constituent oracle is stale")]
ConstituentOracleStale,
#[msg("LP Invariant failed")]
LpInvariantFailed,
#[msg("Invalid constituent derivative weights")]
InvalidConstituentDerivativeWeights,
#[msg("Unauthorized dlp authority")]
UnauthorizedDlpAuthority,
#[msg("Max DLP AUM Breached")]
MaxDlpAumBreached,
#[msg("Settle Lp Pool Disabled")]
SettleLpPoolDisabled,
#[msg("Mint/Redeem Lp Pool Disabled")]
MintRedeemLpPoolDisabled,
#[msg("Settlement amount exceeded")]
LpPoolSettleInvariantBreached,
#[msg("Invalid constituent operation")]
InvalidConstituentOperation,
#[msg("Unauthorized for operation")]
Unauthorized,
}

#[macro_export]
Expand Down
8 changes: 8 additions & 0 deletions programs/drift/src/ids.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use anchor_lang::prelude::Pubkey;
use solana_program::pubkey;

pub mod pyth_program {
use solana_program::declare_id;
#[cfg(feature = "mainnet-beta")]
Expand Down Expand Up @@ -108,6 +111,11 @@ pub mod amm_spread_adjust_wallet {
declare_id!("1ucYHAGrBbi1PaecC4Ptq5ocZLWGLBmbGWysoDGNB1N");
}

pub mod lp_pool_swap_wallet {
use solana_program::declare_id;
declare_id!("25qbsE2oWri76c9a86ubn17NKKdo6Am4HXD2Jm8vT8K4");
}

pub mod dflow_mainnet_aggregator_4 {
use solana_program::declare_id;
declare_id!("DF1ow4tspfHX9JwWJsAb9epbkA8hmpSEAtxXy1V27QBH");
Expand Down
Loading