Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion controller/jiminy/src/account_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ pub fn rebalance_record_checked_mut(
.ok_or(Inf1CtlCustomProgErr(Inf1CtlErr::InvalidRebalanceRecordData))
}

// TODO: refactor to use this fn everywhere
#[inline]
pub fn lst_state_list_get(
list: LstStateList<'_>,
Expand Down
14 changes: 3 additions & 11 deletions controller/program/src/instructions/liquidity/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use inf1_core::{
};
use inf1_ctl_jiminy::{
account_utils::{lst_state_list_checked, pool_state_checked},
accounts::pool_state::PoolState,
cpi::{AddLiquidityPreAccountHandles, LstToSolRetVal, PricingRetVal},
err::Inf1CtlErr,
instructions::{
Expand Down Expand Up @@ -179,11 +178,8 @@ pub fn process_add_liquidity(

lst_sync_sol_val_unchecked(abr, cpi, sync_sol_val_calcs, ix_args.lst_index as usize)?;

let start_total_sol_value = unsafe {
PoolState::of_acc_data(abr.get(*ix_prefix.pool_state()).data())
.ok_or(Inf1CtlCustomProgErr(Inf1CtlErr::InvalidPoolStateData))?
.total_sol_value
};
let start_total_sol_value =
pool_state_checked(abr.get(*ix_prefix.pool_state()))?.total_sol_value;

// Step 4: Calculate sol_value_to_add = LstToSol(amount).min

Expand Down Expand Up @@ -315,11 +311,7 @@ pub fn process_add_liquidity(

lst_sync_sol_val_unchecked(abr, cpi, sync_sol_val_calcs, ix_args.lst_index as usize)?;

let end_total_sol_value = unsafe {
PoolState::of_acc_data(abr.get(*ix_prefix.pool_state()).data())
.ok_or(Inf1CtlCustomProgErr(Inf1CtlErr::InvalidPoolStateData))?
.total_sol_value
};
let end_total_sol_value = pool_state_checked(abr.get(*ix_prefix.pool_state()))?.total_sol_value;

if end_total_sol_value < start_total_sol_value {
return Err(Inf1CtlCustomProgErr(Inf1CtlErr::PoolWouldLoseSolValue).into());
Expand Down