Skip to content

Commit

Permalink
chore: refactor imports
Browse files Browse the repository at this point in the history
  • Loading branch information
chambaz committed Nov 30, 2023
1 parent 966e9fc commit 185c502
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
10 changes: 7 additions & 3 deletions packages/marginfi-v2-ui-state/src/store/jupiterStore.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -42,6 +42,10 @@ const stateCreator: StateCreator<JupiterState, [], []> = (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) => {
Expand Down
20 changes: 9 additions & 11 deletions packages/marginfi-v2-ui-state/src/store/mrgnlendStore.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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;
Expand Down Expand Up @@ -116,6 +111,9 @@ const stateCreator: StateCreator<MrgnlendState, [], []> = (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;
Expand Down

0 comments on commit 185c502

Please sign in to comment.