Skip to content

Commit c768376

Browse files
committed
update dlp types to include lp pool key
1 parent 19efd62 commit c768376

File tree

7 files changed

+54
-8
lines changed

7 files changed

+54
-8
lines changed

.devcontainer/Dockerfile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ RUN mkdir -p /workdir /tmp && \
1919
libssl-dev libudev-dev bash && \
2020
rm -rf /var/lib/apt/lists/*
2121

22+
RUN apt-get install -y software-properties-common \
23+
&& add-apt-repository 'deb http://deb.debian.org/debian bookworm main' \
24+
&& apt-get update && apt-get install -y libc6 libc6-dev
25+
26+
RUN rustup component add rustfmt
27+
2228
RUN rustup install 1.78.0 \
2329
&& rustup component add rustfmt clippy --toolchain 1.78.0
2430

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,5 +94,6 @@
9494
"chalk-template": "<1.1.1",
9595
"supports-hyperlinks": "<4.1.1",
9696
"has-ansi": "<6.0.1"
97-
}
98-
}
97+
},
98+
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
99+
}

programs/drift/src/instructions/keeper.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3333,6 +3333,7 @@ pub fn handle_settle_perp_to_lp_pool<'c: 'info, 'info>(
33333333
ctx.accounts.amm_cache.load_zc_mut()?;
33343334
let quote_market = &mut ctx.accounts.quote_market.load_mut()?;
33353335
let mut quote_constituent = ctx.accounts.constituent.load_mut()?;
3336+
let lp_pool_key = ctx.accounts.lp_pool.key();
33363337
let mut lp_pool = ctx.accounts.lp_pool.load_mut()?;
33373338

33383339
let remaining_accounts_iter = &mut ctx.remaining_accounts.iter().peekable();
@@ -3486,6 +3487,7 @@ pub fn handle_settle_perp_to_lp_pool<'c: 'info, 'info>(
34863487
.cast::<i64>()?,
34873488
lp_aum: lp_pool.last_aum,
34883489
lp_price: lp_pool.get_price(lp_pool.token_supply)?,
3490+
lp_pool: lp_pool_key,
34893491
});
34903492

34913493
// Calculate new quote owed amount

programs/drift/src/instructions/lp_pool.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ pub fn handle_lp_pool_swap<'c: 'info, 'info>(
483483
out_market_target_weight: out_target_weight,
484484
in_swap_id,
485485
out_swap_id,
486+
lp_pool: lp_pool_key,
486487
})?;
487488

488489
receive(
@@ -848,6 +849,7 @@ pub fn handle_lp_pool_add_liquidity<'c: 'info, 'info>(
848849
lp_pool.last_aum,
849850
)?,
850851
in_market_target_weight: in_target_weight,
852+
lp_pool: lp_pool_key,
851853
})?;
852854

853855
Ok(())
@@ -1230,6 +1232,7 @@ pub fn handle_lp_pool_remove_liquidity<'c: 'info, 'info>(
12301232
lp_pool.last_aum,
12311233
)?,
12321234
in_market_target_weight: out_target_weight,
1235+
lp_pool: lp_pool_key,
12331236
})?;
12341237

12351238
Ok(())
@@ -1371,6 +1374,7 @@ pub fn handle_deposit_to_program_vault<'c: 'info, 'info>(
13711374
let remaining_accounts = &mut ctx.remaining_accounts.iter().peekable();
13721375

13731376
let mut constituent = ctx.accounts.constituent.load_mut()?;
1377+
let lp_pool_key = constituent.lp_pool;
13741378

13751379
if amount == 0 {
13761380
return Err(ErrorCode::InsufficientDeposit.into());
@@ -1478,6 +1482,7 @@ pub fn handle_deposit_to_program_vault<'c: 'info, 'info>(
14781482
last_token_balance: constituent.last_spot_balance_token_amount,
14791483
interest_accrued_token_amount,
14801484
amount_deposit_withdraw: amount,
1485+
lp_pool: lp_pool_key,
14811486
});
14821487
constituent.last_spot_balance_token_amount = new_token_balance;
14831488
constituent.cumulative_spot_interest_accrued_token_amount = constituent
@@ -1561,6 +1566,7 @@ pub fn handle_withdraw_from_program_vault<'c: 'info, 'info>(
15611566
last_token_balance: constituent.last_spot_balance_token_amount,
15621567
interest_accrued_token_amount,
15631568
amount_deposit_withdraw: amount,
1569+
lp_pool: constituent.lp_pool,
15641570
});
15651571
constituent.last_spot_balance_token_amount = new_token_balance;
15661572
constituent.cumulative_spot_interest_accrued_token_amount = constituent

programs/drift/src/state/events.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -789,6 +789,8 @@ pub struct LPSettleRecord {
789789
pub lp_aum: u128,
790790
// current mint price of lp
791791
pub lp_price: u128,
792+
// lp pool pubkey
793+
pub lp_pool: Pubkey,
792794
}
793795

794796
#[event]
@@ -830,10 +832,12 @@ pub struct LPSwapRecord {
830832
pub out_market_target_weight: i64,
831833
pub in_swap_id: u64,
832834
pub out_swap_id: u64,
835+
// lp pool pubkey
836+
pub lp_pool: Pubkey,
833837
}
834838

835839
impl Size for LPSwapRecord {
836-
const SIZE: usize = 376;
840+
const SIZE: usize = 408;
837841
}
838842

839843
#[event]
@@ -868,10 +872,12 @@ pub struct LPMintRedeemRecord {
868872
/// PERCENTAGE_PRECISION
869873
pub in_market_current_weight: i64,
870874
pub in_market_target_weight: i64,
875+
// lp pool pubkey
876+
pub lp_pool: Pubkey,
871877
}
872878

873879
impl Size for LPMintRedeemRecord {
874-
const SIZE: usize = 328;
880+
const SIZE: usize = 360;
875881
}
876882

877883
#[event]
@@ -886,8 +892,9 @@ pub struct LPBorrowLendDepositRecord {
886892
pub last_token_balance: i64,
887893
pub interest_accrued_token_amount: i64,
888894
pub amount_deposit_withdraw: u64,
895+
pub lp_pool: Pubkey,
889896
}
890897

891898
impl Size for LPBorrowLendDepositRecord {
892-
const SIZE: usize = 72;
899+
const SIZE: usize = 104;
893900
}

sdk/src/idl/drift.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17672,6 +17672,11 @@
1767217672
"name": "lpPrice",
1767317673
"type": "u128",
1767417674
"index": false
17675+
},
17676+
{
17677+
"name": "lpPool",
17678+
"type": "publicKey",
17679+
"index": false
1767517680
}
1767617681
]
1767717682
},
@@ -17782,6 +17787,11 @@
1778217787
"name": "outSwapId",
1778317788
"type": "u64",
1778417789
"index": false
17790+
},
17791+
{
17792+
"name": "lpPool",
17793+
"type": "publicKey",
17794+
"index": false
1778517795
}
1778617796
]
1778717797
},
@@ -17877,6 +17887,11 @@
1787717887
"name": "inMarketTargetWeight",
1787817888
"type": "i64",
1787917889
"index": false
17890+
},
17891+
{
17892+
"name": "lpPool",
17893+
"type": "publicKey",
17894+
"index": false
1788017895
}
1788117896
]
1788217897
},
@@ -17929,6 +17944,11 @@
1792917944
"name": "amountDepositWithdraw",
1793017945
"type": "u64",
1793117946
"index": false
17947+
},
17948+
{
17949+
"name": "lpPool",
17950+
"type": "publicKey",
17951+
"index": false
1793217952
}
1793317953
]
1793417954
}

sdk/src/types.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -767,6 +767,7 @@ export type LPSwapRecord = {
767767
outMarketTargetWeight: BN;
768768
inSwapId: BN;
769769
outSwapId: BN;
770+
lpPool: PublicKey;
770771
};
771772

772773
export type LPMintRedeemRecord = {
@@ -789,6 +790,7 @@ export type LPMintRedeemRecord = {
789790
lastAumSlot: BN;
790791
inMarketCurrentWeight: BN;
791792
inMarketTargetWeight: BN;
793+
lpPool: PublicKey;
792794
};
793795

794796
export type LPSettleRecord = {
@@ -803,6 +805,7 @@ export type LPSettleRecord = {
803805
perpAmmExFeeDelta: BN;
804806
lpAum: BN;
805807
lpPrice: BN;
808+
lpPool: PublicKey;
806809
};
807810

808811
export type LPBorrowLendDepositRecord = {
@@ -815,6 +818,7 @@ export type LPBorrowLendDepositRecord = {
815818
lastTokenBalance: BN;
816819
interestAccruedTokenAmount: BN;
817820
amountDepositWithdraw: BN;
821+
lpPool: PublicKey;
818822
};
819823

820824
export type StateAccount = {
@@ -1411,9 +1415,9 @@ export interface IWallet {
14111415
publicKey: PublicKey;
14121416
payer?: Keypair;
14131417
supportedTransactionVersions?:
1414-
| ReadonlySet<TransactionVersion>
1415-
| null
1416-
| undefined;
1418+
| ReadonlySet<TransactionVersion>
1419+
| null
1420+
| undefined;
14171421
}
14181422
export interface IVersionedWallet {
14191423
signVersionedTransaction(

0 commit comments

Comments
 (0)