Skip to content

Commit

Permalink
Merge branch 'man0s/stake' of https://github.com/mrgnlabs/mrgn-ts int…
Browse files Browse the repository at this point in the history
…o man0s/stake
  • Loading branch information
k0beLeenders committed Sep 13, 2023
2 parents d2c4502 + c1a0d54 commit 31c4106
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions apps/marginfi-v2-ui/src/store/lstStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { TokenAccount, TokenAccountMap } from "@mrgnlabs/marginfi-v2-ui-state";
import BN from "bn.js";

const NETWORK_FEE_LAMPORTS = 15000; // network fee + some for potential account creation

const SUPPORTED_TOKENS = [
"So11111111111111111111111111111111111111112",
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
Expand Down Expand Up @@ -76,14 +76,13 @@ const stateCreator: StateCreator<LstState, [], []> = (set, get) => ({
let jupiterTokenInfo: TokenInfoMap | null = null;
let userTokenAccounts: TokenAccountMap | null = null;
if (wallet?.publicKey) {
const [accountsAiList, minimumRentExemption, _lstData, _jupiterTokenInfo, _userTokenAccounts] =
await Promise.all([
connection.getMultipleAccountsInfo([wallet.publicKey]),
connection.getMinimumBalanceForRentExemption(ACCOUNT_SIZE),
fetchLstData(connection),
fetchJupiterTokenInfo(),
fetchUserTokenAccounts(connection, wallet.publicKey),
]);
const [accountsAiList, minimumRentExemption, _lstData, _jupiterTokenInfo, _userTokenAccounts] = await Promise.all([
connection.getMultipleAccountsInfo([wallet.publicKey]),
connection.getMinimumBalanceForRentExemption(ACCOUNT_SIZE),
fetchLstData(connection),
fetchJupiterTokenInfo(),
fetchUserTokenAccounts(connection, wallet.publicKey),
]);
lstData = _lstData;
jupiterTokenInfo = _jupiterTokenInfo;
userTokenAccounts = _userTokenAccounts;
Expand Down Expand Up @@ -157,12 +156,10 @@ async function fetchJupiterTokenInfo(): Promise<TokenInfoMap> {
).json();
const res = new TokenListContainer(tokens);
const list = res.filterByChainId(101).getList();
const tokenMap = list
.filter((tokenInfo) => SUPPORTED_TOKENS.includes(tokenInfo.address))
.reduce((acc, item) => {
acc.set(item.address, item);
return acc;
}, new Map());
const tokenMap = list.filter(tokenInfo => SUPPORTED_TOKENS.includes(tokenInfo.address)).reduce((acc, item) => {
acc.set(item.address, item);
return acc;
}, new Map());

return tokenMap;
}
Expand Down

0 comments on commit 31c4106

Please sign in to comment.