Skip to content

Commit

Permalink
Fix kamino withdrawals
Browse files Browse the repository at this point in the history
  • Loading branch information
mvines committed May 10, 2024
1 parent 7a7908e commit 73e941e
Showing 1 changed file with 19 additions and 13 deletions.
32 changes: 19 additions & 13 deletions src/bin/sys-lend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -996,19 +996,25 @@ fn kamino_deposit_or_withdraw(

// Instruction: Kamino: Refresh Reserve

let refresh_reserves = obligation_market_reserves.iter().map(|reserve_address| {
if *reserve_address != market_reserve_address {
(
*reserve_address,
kamino_unsafe_load_reserve(rpc_client, *reserve_address).unwrap_or_else(|err| {
// TODO: propagate failure up instead of panic..
panic!("unable to load reserve {reserve_address}: {err}")
}),
)
} else {
(*reserve_address, reserve)
}
});
let mut refresh_reserves = obligation_market_reserves
.iter()
.filter_map(|reserve_address| {
if *reserve_address != market_reserve_address {
Some((
*reserve_address,
kamino_unsafe_load_reserve(rpc_client, *reserve_address).unwrap_or_else(
|err| {
// TODO: propagate failure up instead of panic..
panic!("unable to load reserve {reserve_address}: {err}")
},
),
))
} else {
None
}
})
.collect::<Vec<_>>();
refresh_reserves.push((market_reserve_address, reserve));

for (reserve_address, reserve) in refresh_reserves {
let pyth_oracle = if reserve.config.token_info.pyth_configuration.price == Pubkey::default()
Expand Down

0 comments on commit 73e941e

Please sign in to comment.