From d9a888337410e2a3910b9e58f979f665c0d7662a Mon Sep 17 00:00:00 2001 From: 0xripleys <0xripleys@solend.fi> Date: Fri, 27 Oct 2023 18:15:33 +0800 Subject: [PATCH] clippy + fmt --- token-lending/program/src/processor.rs | 4 ++-- token-lending/program/tests/helpers/mock_pyth.rs | 2 +- token-lending/sdk/examples/jito.rs | 3 +-- token-lending/sdk/src/lib.rs | 2 +- token-lending/sdk/src/offchain_utils.rs | 11 +++-------- 5 files changed, 8 insertions(+), 14 deletions(-) diff --git a/token-lending/program/src/processor.rs b/token-lending/program/src/processor.rs index e64f223..6310fad 100644 --- a/token-lending/program/src/processor.rs +++ b/token-lending/program/src/processor.rs @@ -530,9 +530,9 @@ fn _refresh_reserve<'a>( /// Lite version of refresh_reserve that should be used when the oracle price doesn't need to be updated /// BE CAREFUL WHEN USING THIS -fn _refresh_reserve_interest<'a>( +fn _refresh_reserve_interest( program_id: &Pubkey, - reserve_info: &AccountInfo<'a>, + reserve_info: &AccountInfo<'_>, clock: &Clock, ) -> ProgramResult { let mut reserve = Reserve::unpack(&reserve_info.data.borrow())?; diff --git a/token-lending/program/tests/helpers/mock_pyth.rs b/token-lending/program/tests/helpers/mock_pyth.rs index 0deac09..9d7f331 100644 --- a/token-lending/program/tests/helpers/mock_pyth.rs +++ b/token-lending/program/tests/helpers/mock_pyth.rs @@ -127,7 +127,7 @@ impl Processor { msg!("Mock Pyth: Set price"); let price_account_info = next_account_info(account_info_iter)?; let data = &mut price_account_info.try_borrow_mut_data()?; - let mut price_account: &mut PriceAccount = load_mut(data).unwrap(); + let price_account: &mut PriceAccount = load_mut(data).unwrap(); price_account.agg.price = price; price_account.agg.conf = conf; diff --git a/token-lending/sdk/examples/jito.rs b/token-lending/sdk/examples/jito.rs index d95dddc..438dfab 100644 --- a/token-lending/sdk/examples/jito.rs +++ b/token-lending/sdk/examples/jito.rs @@ -63,8 +63,7 @@ pub fn main() { .entry(obligation.owner) .or_insert(Position::default()); - position.borrow_balance += - borrow.borrowed_amount_wads.try_round_u64().unwrap(); + position.borrow_balance += borrow.borrowed_amount_wads.try_round_u64().unwrap(); } } } diff --git a/token-lending/sdk/src/lib.rs b/token-lending/sdk/src/lib.rs index 9cee0e1..940ecaf 100644 --- a/token-lending/sdk/src/lib.rs +++ b/token-lending/sdk/src/lib.rs @@ -5,9 +5,9 @@ pub mod error; pub mod instruction; pub mod math; +pub mod offchain_utils; pub mod oracles; pub mod state; -pub mod offchain_utils; // Export current sdk types for downstream users building with a different sdk version pub use solana_program; diff --git a/token-lending/sdk/src/offchain_utils.rs b/token-lending/sdk/src/offchain_utils.rs index d37e76b..f1f2968 100644 --- a/token-lending/sdk/src/offchain_utils.rs +++ b/token-lending/sdk/src/offchain_utils.rs @@ -1,21 +1,16 @@ #![allow(missing_docs)] -use crate::{self as solend_program, error::LendingError}; -use pyth_sdk_solana::Price; + use solana_client::rpc_client::RpcClient; use solana_program::slot_history::Slot; // use pyth_sdk_solana; -use solana_program::{ - account_info::AccountInfo, msg, program_error::ProgramError, sysvar::clock::Clock, -}; -use std::{convert::TryInto, result::Result}; +use solana_program::program_error::ProgramError; +use std::result::Result; use crate::{state::LastUpdate, NULL_PUBKEY}; -use std::time::Duration; use solana_program::{program_pack::Pack, pubkey::Pubkey}; use crate::math::{Decimal, Rate, TryAdd, TryMul}; -use std::collections::HashSet; use crate::state::{LendingMarket, Obligation, Reserve}; use std::{collections::HashMap, error::Error};