Skip to content

Commit

Permalink
fix: use accountMap
Browse files Browse the repository at this point in the history
  • Loading branch information
ZhengYuTay authored and Arrowana committed Sep 18, 2024
1 parent b636f3e commit 489f7cd
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
8 changes: 4 additions & 4 deletions jup_interface/src/pool_sol/deposit_sol.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
use anyhow::{anyhow, Result};
use jupiter_amm_interface::{
Amm, AmmContext, KeyedAccount, Quote, QuoteParams, Swap, SwapAndAccountMetas, SwapParams,
AccountMap, Amm, AmmContext, KeyedAccount, Quote, QuoteParams, Swap, SwapAndAccountMetas,
SwapParams,
};
use solana_sdk::{account::Account, instruction::AccountMeta, pubkey::Pubkey, system_program};
use solana_sdk::{instruction::AccountMeta, pubkey::Pubkey, system_program};
use spl_token::native_mint;
use stakedex_interface::{StakeWrappedSolKeys, STAKE_WRAPPED_SOL_IX_ACCOUNTS_LEN};
use stakedex_sdk_common::{
find_deposit_stake_amm_key, find_fee_token_acc, spl_deposit_cap_guard_program,
stakedex_program, wsol_bridge_in, DepositSol, InitFromKeyedAccount, TEMPORARY_JUP_AMM_LABEL,
};
use std::collections::HashMap;

use crate::jupiter_stakedex_interface::STAKEDEX_ACCOUNT_META;

Expand Down Expand Up @@ -43,7 +43,7 @@ where
self.0.get_accounts_to_update()
}

fn update(&mut self, accounts_map: &HashMap<Pubkey, Account>) -> Result<()> {
fn update(&mut self, accounts_map: &AccountMap) -> Result<()> {
self.0.update(accounts_map)
}

Expand Down
8 changes: 4 additions & 4 deletions stakedex_sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ pub struct Stakedex {
pub lido: LidoStakedex,
}

fn get_keyed_account(accounts: &HashMap<Pubkey, Account>, key: &Pubkey) -> Result<KeyedAccount> {
fn get_keyed_account(accounts: &AccountMap, key: &Pubkey) -> Result<KeyedAccount> {
Ok(KeyedAccount {
key: *key,
account: accounts
Expand All @@ -78,7 +78,7 @@ fn get_keyed_account(accounts: &HashMap<Pubkey, Account>, key: &Pubkey) -> Resul
}

fn init_from_keyed_account_no_params<P: InitFromKeyedAccount>(
accounts: &HashMap<Pubkey, Account>,
accounts: &AccountMap,
key: &Pubkey,
) -> Result<P> {
let keyed_acc = get_keyed_account(accounts, key)?;
Expand Down Expand Up @@ -116,7 +116,7 @@ impl Stakedex {
/// `sanctum_lsts` must be the same iterator passed to [`Self::init_accounts()`]
pub fn from_fetched_accounts<'a>(
sanctum_lsts: impl Iterator<Item = &'a SanctumLst>,
accounts: &HashMap<Pubkey, Account>,
accounts: &AccountMap,
) -> (Self, Vec<anyhow::Error>) {
// So that stakedex is still useable even if some pools fail to load
let mut errs = Vec::new();
Expand Down Expand Up @@ -220,7 +220,7 @@ impl Stakedex {
})
}

pub fn update(&mut self, account_map: &HashMap<Pubkey, Account>) -> Vec<anyhow::Error> {
pub fn update(&mut self, account_map: &AccountMap) -> Vec<anyhow::Error> {
// unstake.it special-case: required reinitialization to save sol_reserves_lamports correctly
let maybe_unstake_it_init_err = match init_from_keyed_account_no_params(
account_map,
Expand Down
4 changes: 2 additions & 2 deletions stakedex_sdk/tests/test_main.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use jupiter_amm_interface::{Quote, QuoteParams, SwapMode, SwapParams};
use jupiter_amm_interface::{AccountMap, Quote, QuoteParams, SwapMode, SwapParams};
use lazy_static::lazy_static;
use sanctum_lst_list::SanctumLstList;
use solana_account_decoder::UiAccountEncoding;
Expand Down Expand Up @@ -62,7 +62,7 @@ lazy_static! {
};
}

fn fetch_accounts(accounts_pubkeys: &[Pubkey]) -> HashMap<Pubkey, Account> {
fn fetch_accounts(accounts_pubkeys: &[Pubkey]) -> AccountMap {
let fetched = RPC.get_multiple_accounts(accounts_pubkeys).unwrap();
zip(accounts_pubkeys, fetched)
.filter_map(|(pubkey, opt)| match opt {
Expand Down

0 comments on commit 489f7cd

Please sign in to comment.