Skip to content

Commit d5643a1

Browse files
committed
remove incorrect usage of nav
1 parent c00ebb6 commit d5643a1

File tree

5 files changed

+9
-29
lines changed

5 files changed

+9
-29
lines changed

programs/drift/src/instructions/lp_pool.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@ pub fn handle_lp_pool_add_liquidity<'c: 'info, 'info>(
889889
in_constituent.sync_token_balance(ctx.accounts.constituent_in_token_account.amount);
890890

891891
let dlp_total_supply = ctx.accounts.lp_mint.supply;
892-
let lp_nav = if dlp_total_supply > 0 {
892+
let lp_price = if dlp_total_supply > 0 {
893893
lp_pool.last_aum.safe_div(dlp_total_supply as u128)?
894894
} else {
895895
0
@@ -910,7 +910,7 @@ pub fn handle_lp_pool_add_liquidity<'c: 'info, 'info>(
910910
lp_mint: lp_pool.mint,
911911
lp_amount,
912912
lp_fee: lp_fee_amount,
913-
lp_nav,
913+
lp_price,
914914
mint_redeem_id,
915915
last_aum: lp_pool.last_aum,
916916
last_aum_slot: lp_pool.last_aum_slot,
@@ -1086,7 +1086,7 @@ pub fn handle_lp_pool_remove_liquidity<'c: 'info, 'info>(
10861086
out_constituent.sync_token_balance(ctx.accounts.constituent_out_token_account.amount);
10871087

10881088
let dlp_total_supply = ctx.accounts.lp_mint.supply;
1089-
let lp_nav = if dlp_total_supply > 0 {
1089+
let lp_price = if dlp_total_supply > 0 {
10901090
lp_pool.last_aum.safe_div(dlp_total_supply as u128)?
10911091
} else {
10921092
0
@@ -1107,7 +1107,7 @@ pub fn handle_lp_pool_remove_liquidity<'c: 'info, 'info>(
11071107
lp_mint: lp_pool.mint,
11081108
lp_amount: lp_burn_amount,
11091109
lp_fee: lp_fee_amount,
1110-
lp_nav,
1110+
lp_price,
11111111
mint_redeem_id,
11121112
last_aum: lp_pool.last_aum,
11131113
last_aum_slot: lp_pool.last_aum_slot,

programs/drift/src/state/events.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -804,8 +804,8 @@ pub struct LPMintRedeemRecord {
804804
pub lp_amount: u64,
805805
/// lp fee, lp mint precision
806806
pub lp_fee: i64,
807-
/// lp nav, PRICE_PRECISION
808-
pub lp_nav: u128,
807+
/// the fair price of the lp token, PRICE_PRECISION
808+
pub lp_price: u128,
809809
pub mint_redeem_id: u64,
810810
/// LPPool last_aum
811811
pub last_aum: u128,

programs/drift/src/state/lp_pool.rs

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,6 @@ pub struct LPPool {
6161
// vault token mint
6262
pub mint: Pubkey, // 32, 96
6363

64-
/// token_supply? to simplify NAV calculation, or load from mint account
65-
/// token_total_supply: u64
66-
6764
/// The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)
6865
/// which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)
6966
/// pub quote_constituent_index: u16,
@@ -118,18 +115,6 @@ impl Size for LPPool {
118115
}
119116

120117
impl LPPool {
121-
pub fn get_nav(&self, mint: &Mint) -> Result<u128> {
122-
match mint.supply {
123-
0 => Ok(0),
124-
supply => {
125-
// TODO: assuming mint decimals = quote decimals = 6
126-
self.last_aum
127-
.checked_div(supply.into())
128-
.ok_or(ErrorCode::MathError.into())
129-
}
130-
}
131-
}
132-
133118
pub fn get_price(&self, mint: &Mint) -> Result<u128> {
134119
match mint.supply {
135120
0 => Ok(0),

sdk/src/idl/drift.json

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9224,8 +9224,6 @@
92249224
{
92259225
"name": "maxAum",
92269226
"docs": [
9227-
"token_supply? to simplify NAV calculation, or load from mint account",
9228-
"token_total_supply: u64",
92299227
"The current number of VaultConstituents in the vault, each constituent is pda(LPPool.address, constituent_index)",
92309228
"which constituent is the quote, receives revenue pool distributions. (maybe this should just be implied idx 0)",
92319229
"pub quote_constituent_index: u16,",
@@ -16587,7 +16585,7 @@
1658716585
"index": false
1658816586
},
1658916587
{
16590-
"name": "lpNav",
16588+
"name": "lpPrice",
1659116589
"type": "u128",
1659216590
"index": false
1659316591
},
@@ -18265,8 +18263,5 @@
1826518263
"name": "ConstituentOracleStale",
1826618264
"msg": "Constituent oracle is stale"
1826718265
}
18268-
],
18269-
"metadata": {
18270-
"address": "dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH"
18271-
}
18266+
]
1827218267
}

sdk/src/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -766,7 +766,7 @@ export type LPMintRedeemRecord = {
766766
lpMint: PublicKey;
767767
lpAmount: BN;
768768
lpFee: BN;
769-
lpNav: BN;
769+
lpPrice: BN;
770770
mintRedeemId: BN;
771771
lastAum: BN;
772772
lastAumSlot: BN;

0 commit comments

Comments
 (0)