Skip to content

Commit 09c8744

Browse files
committed
Fixing ix mutable borrows
1 parent 881056e commit 09c8744

File tree

3 files changed

+21
-19
lines changed

3 files changed

+21
-19
lines changed

token-lending/program/tests/helpers/solend_program_test.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,21 @@ use super::mock_pyth_pull::{init as init_pull, set_price as set_price_pull};
5959

6060
mod cu_budgets {
6161
pub(super) const INIT_OBLIGATION: u32 = 10_001;
62-
pub(super) const DEPOSIT_OBLIGATION_COLLATERAL: u32 = 38_002;
62+
pub(super) const DEPOSIT_OBLIGATION_COLLATERAL: u32 = 70_002;
6363
pub(super) const REFRESH_RESERVE: u32 = 2_000_003;
6464
pub(super) const REFRESH_OBLIGATION: u32 = 1_000_004;
6565
pub(super) const BORROW_OBLIGATION_LIQUIDITY: u32 = 180_005;
66-
pub(super) const REPAY_OBLIGATION_LIQUIDITY: u32 = 35_006;
66+
pub(super) const REPAY_OBLIGATION_LIQUIDITY: u32 = 70_006;
6767
pub(super) const REDEEM_FEES: u32 = 80_007;
68-
pub(super) const LIQUIDATE_OBLIGATION_AND_REDEEM_RESERVE_COLLATERAL: u32 = 180_008;
69-
pub(super) const WITHDRAW_OBLIGATION_COLLATERAL_AND_REDEEM_RESERVE_COLLATERAL: u32 = 110_009;
68+
pub(super) const LIQUIDATE_OBLIGATION_AND_REDEEM_RESERVE_COLLATERAL: u32 = 230_008;
69+
pub(super) const WITHDRAW_OBLIGATION_COLLATERAL_AND_REDEEM_RESERVE_COLLATERAL: u32 = 200_009;
7070
pub(super) const WITHDRAW_OBLIGATION_COLLATERAL: u32 = 130_010;
7171
pub(super) const INIT_RESERVE: u32 = 90_011;
72-
pub(super) const DEPOSIT: u32 = 50_012;
72+
pub(super) const DEPOSIT: u32 = 70_012;
7373
pub(super) const DONATE_TO_RESERVE: u32 = 50_013;
7474
pub(super) const UPDATE_RESERVE_CONFIG: u32 = 30_014;
75-
pub(super) const DEPOSIT_RESERVE_LIQUIDITY_AND_OBLIGATION_COLLATERAL: u32 = 100_015;
76-
pub(super) const REDEEM: u32 = 58_016;
75+
pub(super) const DEPOSIT_RESERVE_LIQUIDITY_AND_OBLIGATION_COLLATERAL: u32 = 130_015;
76+
pub(super) const REDEEM: u32 = 90_016;
7777
}
7878

7979
/// This is at most how many bytes can an obligation grow.

token-lending/sdk/src/instruction.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1630,7 +1630,7 @@ pub fn withdraw_obligation_collateral_and_redeem_reserve_collateral(
16301630
AccountMeta::new(destination_liquidity_pubkey, false),
16311631
AccountMeta::new(reserve_collateral_mint_pubkey, false),
16321632
AccountMeta::new(reserve_liquidity_supply_pubkey, false),
1633-
AccountMeta::new_readonly(obligation_owner_pubkey, true),
1633+
AccountMeta::new(obligation_owner_pubkey, true),
16341634
AccountMeta::new_readonly(user_transfer_authority_pubkey, true),
16351635
AccountMeta::new_readonly(spl_token::id(), false),
16361636
];
@@ -1672,7 +1672,7 @@ pub fn withdraw_obligation_collateral(
16721672
let mut accounts = vec![
16731673
AccountMeta::new(source_collateral_pubkey, false),
16741674
AccountMeta::new(destination_collateral_pubkey, false),
1675-
AccountMeta::new_readonly(withdraw_reserve_pubkey, false),
1675+
AccountMeta::new(withdraw_reserve_pubkey, false),
16761676
AccountMeta::new(obligation_pubkey, false),
16771677
AccountMeta::new_readonly(lending_market_pubkey, false),
16781678
AccountMeta::new_readonly(lending_market_authority_pubkey, false),
@@ -1790,7 +1790,7 @@ pub fn liquidate_obligation(
17901790
AccountMeta::new(destination_collateral_pubkey, false),
17911791
AccountMeta::new(repay_reserve_pubkey, false),
17921792
AccountMeta::new(repay_reserve_liquidity_supply_pubkey, false),
1793-
AccountMeta::new_readonly(withdraw_reserve_pubkey, false),
1793+
AccountMeta::new(withdraw_reserve_pubkey, false),
17941794
AccountMeta::new(withdraw_reserve_collateral_supply_pubkey, false),
17951795
AccountMeta::new(obligation_pubkey, false),
17961796
AccountMeta::new_readonly(lending_market_pubkey, false),

token-lending/sdk/src/state/liquidity_mining.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,9 @@ pub enum PoolRewardSlot {
6868
last_pool_reward_id: PoolRewardId,
6969
/// An optimization to avoid writing data that has not changed.
7070
/// When vacating a slot we set this to true.
71-
has_been_vacated_in_this_tx: bool,
71+
/// That way the packing logic knows whether it's fine to skip the
72+
/// packing or not.
73+
has_been_just_vacated: bool,
7274
},
7375
/// Reward has not been closed yet.
7476
///
@@ -309,7 +311,7 @@ impl PoolRewardManager {
309311

310312
self.pool_rewards[pool_reward_index] = PoolRewardSlot::Vacant {
311313
last_pool_reward_id: pool_reward.id,
312-
has_been_vacated_in_this_tx: true,
314+
has_been_just_vacated: true,
313315
};
314316

315317
Ok(vault)
@@ -689,7 +691,7 @@ impl Default for PoolRewardSlot {
689691
last_pool_reward_id: PoolRewardId(0),
690692
// this is used for initialization of the pool reward manager so
691693
// it makes sense as there are 0s in the account data already
692-
has_been_vacated_in_this_tx: false,
694+
has_been_just_vacated: false,
693695
}
694696
}
695697
}
@@ -793,7 +795,7 @@ impl Pack for PoolRewardManager {
793795
PoolRewardSlot::Vacant {
794796
last_pool_reward_id: pool_reward_id,
795797
// nope, has been vacant since unpack
796-
has_been_vacated_in_this_tx: false,
798+
has_been_just_vacated: false,
797799
}
798800
} else {
799801
let raw_pool_reward_tail =
@@ -838,7 +840,7 @@ impl PoolRewardSlot {
838840
let for_sure_has_not_changed = matches!(
839841
self,
840842
Self::Vacant {
841-
has_been_vacated_in_this_tx: false,
843+
has_been_just_vacated: false,
842844
..
843845
}
844846
);
@@ -1084,7 +1086,7 @@ mod tests {
10841086
let mut m = PoolRewardManager::default();
10851087
m.pool_rewards[0] = PoolRewardSlot::Vacant {
10861088
last_pool_reward_id: PoolRewardId(69),
1087-
has_been_vacated_in_this_tx: true,
1089+
has_been_just_vacated: true,
10881090
};
10891091

10901092
let mut packed = vec![0u8; PoolRewardManager::LEN];
@@ -1095,7 +1097,7 @@ mod tests {
10951097
unpacked.pool_rewards[0],
10961098
PoolRewardSlot::Vacant {
10971099
last_pool_reward_id: PoolRewardId(69),
1098-
has_been_vacated_in_this_tx: false,
1100+
has_been_just_vacated: false,
10991101
}
11001102
);
11011103
}
@@ -1112,7 +1114,7 @@ mod tests {
11121114
pool_reward,
11131115
PoolRewardSlot::Vacant {
11141116
last_pool_reward_id: PoolRewardId(0),
1115-
has_been_vacated_in_this_tx: false,
1117+
has_been_just_vacated: false,
11161118
}
11171119
)
11181120
});
@@ -1595,7 +1597,7 @@ mod tests {
15951597
if is_vacant {
15961598
PoolRewardSlot::Vacant {
15971599
last_pool_reward_id: Default::default(),
1598-
has_been_vacated_in_this_tx: false,
1600+
has_been_just_vacated: false,
15991601
}
16001602
} else {
16011603
PoolRewardSlot::Occupied(Box::new(PoolReward {

0 commit comments

Comments
 (0)