Skip to content

Commit e9ccb2b

Browse files
committed
sys-lend: fix up solend-jlp support
1 parent db4b7cb commit e9ccb2b

File tree

1 file changed

+36
-19
lines changed

1 file changed

+36
-19
lines changed

src/bin/sys-lend.rs

+36-19
Original file line numberDiff line numberDiff line change
@@ -2485,6 +2485,8 @@ fn kamino_deposit_or_withdraw(
24852485
///[ Solend Stuff ] //////////////////////////////////////////////////////////
24862486
//////////////////////////////////////////////////////////////////////////////
24872487

2488+
const SOLEND_JLP_EXTRA_ORACLE: Pubkey = pubkey!["BjUgj6YCnFBZ49wF54ddBVA9qu8TeqkFtkbqmZcee8uW"];
2489+
24882490
fn solend_load_reserve(
24892491
reserve_address: Pubkey,
24902492
account_data_cache: &mut AccountDataCache,
@@ -2498,18 +2500,27 @@ fn solend_load_reserve(
24982500
// read back the new reserve account data to ensure it's up to date
24992501
//
25002502

2503+
let mut refresh_reserve_account_metas = vec![
2504+
// Reserve
2505+
AccountMeta::new(reserve_address, false),
2506+
// Pyth Oracle
2507+
AccountMeta::new_readonly(rpc_reserve.liquidity.pyth_oracle_pubkey, false),
2508+
// Switchboard Oracle
2509+
AccountMeta::new_readonly(rpc_reserve.liquidity.switchboard_oracle_pubkey, false),
2510+
];
2511+
2512+
// "Extra oracle" for solend-jlp's USDC reserve
2513+
// TODO: Figure out how to determine `SOLEND_JLP_EXTRA_ORACLE` from on-chain data
2514+
if reserve_address == pubkey!["GShhnkfbaYy41Fd8vSEk9zoiwZSKqbH1j16jZ2afV2GG"] {
2515+
refresh_reserve_account_metas
2516+
.push(AccountMeta::new_readonly(SOLEND_JLP_EXTRA_ORACLE, false));
2517+
}
2518+
25012519
// Instruction: Solend: Refresh Reserve
25022520
let instructions = vec![Instruction::new_with_bytes(
25032521
solend::solend_mainnet::ID,
25042522
&[3],
2505-
vec![
2506-
// Reserve
2507-
AccountMeta::new(reserve_address, false),
2508-
// Pyth Oracle
2509-
AccountMeta::new_readonly(rpc_reserve.liquidity.pyth_oracle_pubkey, false),
2510-
// Switchboard Oracle
2511-
AccountMeta::new_readonly(rpc_reserve.liquidity.switchboard_oracle_pubkey, false),
2512-
],
2523+
refresh_reserve_account_metas,
25132524
)];
25142525

25152526
account_data_cache.simulate_then_add(&instructions, None, &[])?;
@@ -2788,20 +2799,26 @@ fn solend_deposit_or_withdraw(
27882799
refresh_reserves.push((market_reserve_address, reserve.clone()));
27892800

27902801
for (reserve_address, reserve) in refresh_reserves {
2802+
let mut refresh_reserve_account_metas = vec![
2803+
// Reserve
2804+
AccountMeta::new(reserve_address, false),
2805+
// Pyth Oracle
2806+
AccountMeta::new_readonly(reserve.liquidity.pyth_oracle_pubkey, false),
2807+
// Switchboard Oracle
2808+
AccountMeta::new_readonly(reserve.liquidity.switchboard_oracle_pubkey, false),
2809+
];
2810+
2811+
// "Extra oracle" for solend-jlp's USDC reserve
2812+
// TODO: Figure out how to determine `SOLEND_JLP_EXTRA_ORACLE` from on-chain data
2813+
if reserve_address == pubkey!["GShhnkfbaYy41Fd8vSEk9zoiwZSKqbH1j16jZ2afV2GG"] {
2814+
refresh_reserve_account_metas
2815+
.push(AccountMeta::new_readonly(SOLEND_JLP_EXTRA_ORACLE, false));
2816+
}
2817+
27912818
instructions.push(Instruction::new_with_bytes(
27922819
solend::solend_mainnet::ID,
27932820
&[3],
2794-
vec![
2795-
// Reserve
2796-
AccountMeta::new(reserve_address, false),
2797-
// Pyth Oracle
2798-
AccountMeta::new_readonly(reserve.liquidity.pyth_oracle_pubkey, false),
2799-
// Switchboard Oracle
2800-
AccountMeta::new_readonly(
2801-
reserve.liquidity.switchboard_oracle_pubkey,
2802-
false,
2803-
),
2804-
],
2821+
refresh_reserve_account_metas,
28052822
));
28062823
}
28072824

0 commit comments

Comments
 (0)