diff --git a/apps/marginfi-v2-ui/src/hooks/useWalletContext.tsx b/apps/marginfi-v2-ui/src/hooks/useWalletContext.tsx index ed760f5b43..bad314363c 100644 --- a/apps/marginfi-v2-ui/src/hooks/useWalletContext.tsx +++ b/apps/marginfi-v2-ui/src/hooks/useWalletContext.tsx @@ -1,7 +1,6 @@ import React from "react"; import { useRouter } from "next/router"; -import { toast } from "react-toastify"; import { useCookies } from "react-cookie"; import { minidenticon } from "minidenticons"; import { useAnchorWallet, useWallet, WalletContextState } from "@solana/wallet-adapter-react"; @@ -11,10 +10,11 @@ import { Web3AuthNoModal } from "@web3auth/no-modal"; import { OpenloginAdapter } from "@web3auth/openlogin-adapter"; import { SolanaWallet, SolanaPrivateKeyProvider } from "@web3auth/solana-provider"; import base58 from "bs58"; -import { Wallet } from "@mrgnlabs/mrgn-common"; import { showErrorToast } from "~/utils/toastUtils"; +import type { Wallet } from "@mrgnlabs/mrgn-common"; + // wallet adapter context type to override with web3auth data // this allows us to pass web3auth wallet to 3rd party services that expect wallet adapter type WalletContextOverride = { diff --git a/apps/marginfi-v2-ui/src/store/lstStore.ts b/apps/marginfi-v2-ui/src/store/lstStore.ts index 2a48fc8c32..dc4641c184 100644 --- a/apps/marginfi-v2-ui/src/store/lstStore.ts +++ b/apps/marginfi-v2-ui/src/store/lstStore.ts @@ -4,11 +4,12 @@ import { Connection, PublicKey } from "@solana/web3.js"; import { create, StateCreator } from "zustand"; import * as solanaStakePool from "@solana/spl-stake-pool"; import { EPOCHS_PER_YEAR, StakeData, fetchStakeAccounts } from "~/utils"; -import { TokenInfo, TokenInfoMap, TokenListContainer } from "@solana/spl-token-registry"; import { TokenAccount, TokenAccountMap, fetchBirdeyePrices } from "@mrgnlabs/marginfi-v2-ui-state"; import { persist } from "zustand/middleware"; import BN from "bn.js"; +import type { TokenInfo, TokenInfoMap } from "@solana/spl-token-registry"; + const STAKEVIEW_APP_URL = "https://stakeview.app/apy/prev3.json"; const BASELINE_VALIDATOR_ID = "mrgn28BhocwdAUEenen3Sw2MR9cPKDpLkDvzDdR7DBD"; @@ -259,6 +260,10 @@ async function fetchJupiterTokenInfo(): Promise { ? await fetch("https://token.jup.ag/strict") : await fetch("https://token.jup.ag/all") ).json(); + + // Dynamically import TokenListContainer when needed + const { TokenListContainer } = await import("@solana/spl-token-registry"); + const res = new TokenListContainer(tokens); const list = res.filterByChainId(101).getList(); const tokenMap = list diff --git a/apps/marginfi-v2-ui/src/store/uiStore.ts b/apps/marginfi-v2-ui/src/store/uiStore.ts index 7ead4b1942..f57275c55e 100644 --- a/apps/marginfi-v2-ui/src/store/uiStore.ts +++ b/apps/marginfi-v2-ui/src/store/uiStore.ts @@ -69,7 +69,7 @@ const stateCreator: StateCreator = (set, get) => ({ isFilteredUserPositions: false, lendingMode: LendingModes.LEND, poolFilter: PoolTypes.ALL, - sortOption: SORT_OPTIONS_MAP[SortType.APY_DESC], + sortOption: SORT_OPTIONS_MAP[SortType.TVL_DESC], // Actions setIsMenuDrawerOpen: (isOpen: boolean) => set({ isMenuDrawerOpen: isOpen }), diff --git a/packages/marginfi-v2-ui-state/src/store/jupiterStore.ts b/packages/marginfi-v2-ui-state/src/store/jupiterStore.ts index 083fccc200..c9284c08b5 100644 --- a/packages/marginfi-v2-ui-state/src/store/jupiterStore.ts +++ b/packages/marginfi-v2-ui-state/src/store/jupiterStore.ts @@ -1,9 +1,9 @@ -import { Wallet, nativeToUi, TOKEN_PROGRAM_ID } from "@mrgnlabs/mrgn-common"; -import { TokenInfo, TokenListContainer } from "@solana/spl-token-registry"; +import { Wallet, TOKEN_PROGRAM_ID } from "@mrgnlabs/mrgn-common"; import { Connection, PublicKey } from "@solana/web3.js"; import { TokenAccountMap, TokenAccount } from "../lib"; import { create, StateCreator } from "zustand"; -import { BN } from "@coral-xyz/anchor"; + +import type { TokenInfo } from "@solana/spl-token-registry"; interface JupiterState { // State @@ -42,6 +42,10 @@ const stateCreator: StateCreator = (set, get) => ({ ? await fetch("https://token.jup.ag/strict") : await fetch("https://token.jup.ag/all") ).json(); + + // Dynamically import TokenListContainer when needed + const { TokenListContainer } = await import("@solana/spl-token-registry"); + const res = new TokenListContainer(tokens); const list = res.filterByChainId(101).getList(); tokenMap = list.reduce((acc, item) => { diff --git a/packages/marginfi-v2-ui-state/src/store/mrgnlendStore.ts b/packages/marginfi-v2-ui-state/src/store/mrgnlendStore.ts index 868e48e5ab..c78efb32dd 100644 --- a/packages/marginfi-v2-ui-state/src/store/mrgnlendStore.ts +++ b/packages/marginfi-v2-ui-state/src/store/mrgnlendStore.ts @@ -1,14 +1,4 @@ -import { MarginfiAccountWrapper, MarginfiClient, MarginfiConfig } from "@mrgnlabs/marginfi-client-v2"; -import { - Wallet, - getValueInsensitive, - loadBankMetadatas, - loadTokenMetadatas, - BankMetadataMap, - TokenMetadataMap, - TokenMetadata, -} from "@mrgnlabs/mrgn-common"; -import { Bank, OraclePrice } from "@mrgnlabs/marginfi-client-v2"; +import { getValueInsensitive } from "@mrgnlabs/mrgn-common"; import { Connection, PublicKey } from "@solana/web3.js"; import { DEFAULT_ACCOUNT_SUMMARY, @@ -28,6 +18,11 @@ import { getPointsSummary } from "../lib/points"; import { create, StateCreator } from "zustand"; import { persist } from "zustand/middleware"; +import type { Bank, OraclePrice } from "@mrgnlabs/marginfi-client-v2"; +import type { Wallet, BankMetadataMap, TokenMetadataMap, TokenMetadata } from "@mrgnlabs/mrgn-common"; +import type { MarginfiAccountWrapper } from "@mrgnlabs/marginfi-client-v2"; +import type { MarginfiClient, MarginfiConfig } from "@mrgnlabs/marginfi-client-v2"; + interface ProtocolStats { deposits: number; borrows: number; @@ -116,6 +111,9 @@ const stateCreator: StateCreator = (set, get) => ({ birdEyeApiKey?: string; }) => { try { + const { MarginfiClient } = await import("@mrgnlabs/marginfi-client-v2"); + const { loadBankMetadatas, loadTokenMetadatas } = await import("@mrgnlabs/mrgn-common"); + let userDataFetched = false; const connection = args?.connection ?? get().marginfiClient?.provider.connection;